HTML Formatting
HTML formatting elements are used to define how text should appear on a web page. These elements allow you to highlight important content, emphasize text, and improve readability for users.
HTML <b> and <strong> Elements
The <b> element makes text bold without adding extra importance.
The <strong> element represents important text and is also bold.
<!DOCTYPE html> <html> <body> <strong>This is important text</strong> </body> </html>Try this code
HTML <i> and <em> Elements
The <i> element displays text in italic style without emphasis.
The <em> element emphasizes text and is typically displayed in italics.
<!DOCTYPE html> <html> <body> <em>This is emphasized text</em> </body> </html>Try this code
HTML <u> Elements
The <u> element underlines text.
It should be used carefully because underlined text is often confused with links.
HTML <small> Elements
The <small> element defines smaller text, often used for notes or disclaimers.
<!DOCTYPE html> <html> <body> <small>This is small text</small> </body> </html>Try this code
HTML <mark> Elements
The <mark> element highlights text with a background color.
<!DOCTYPE html> <html> <body> <mark>This is highlighted text</mark> </body> </html>Try this code
HTML <del> and <ins> Elements
The <del> element shows deleted text, usually displayed with a line through it.
<ins> element shows inserted text, often underlined.
<!DOCTYPE html> <html> <body> <ins>This is inserted text</ins> </body> </html>Try this code
HTML <sub> Elements
The <sub> element displays text as subscript.
<!DOCTYPE html> <html> <body> <sub>This is subscripted text</sub> </body> </html>Try this code
HTML <sup> Elements
The <sup> element displays text as superscript.
<!DOCTYPE html> <html> <body> <sup>This is superscripted text</sup> </body> </html>Try this code
Formatting Best Practices
- Use
<strong>and<em>for meaning, not just styling - Avoid excessive formatting
- Keep text readable and clean
- Use CSS for visual styling when possible
Common Formatting Mistakes
- Using formatting tags only for design
- Overusing bold or italic text
- Mixing formatting styles unnecessarily
- Ignoring semantic meaning