HTML Basics

HTML Formatting

HTML provides tags to format text on your web page - making it bold, italic, highlighted, or styled semantically for emphasis.
Formatting improves readability and helps users understand important content.

Bold and Strong Text

  • <b> - Makes text bold, purely for visual effect.
  • <strong> - Makes text bold and adds semantic importance for accessibility and SEO.

Formatting Example

html

<p>This is <b>bold text</b>.</p>
<p>This is <strong>strong important text</strong>.</p>

Italic and Emphasized Text

  • <i> - Italicizes text for stylistic purposes.
  • <em> - Emphasizes text semantically, read as important by screen readers.

Formatting Example

html

<p>This is <i>italic text</i>.</p>
<p>This is <em>emphasized text</em>.</p>

Underline and Mark

  • <u> - Underlines text (visual only).
  • <mark> - Highlights text (like a yellow marker).

Formatting Example

html

<p>This is <u>underlined text</u>.</p>
<p>This is <mark>highlighted text</mark>.</p>

Subscript and Superscript

  • <sub> - Subscript text (appears slightly below baseline)
  • <sup> - Superscript text (appears slightly above baseline)

Formatting Example

html

<p>H<sub>2</sub>O is water.</p>
<p>E = mc<sup>2</sup> is Einstein's formula.</p>

Small and Deleted Text

  • <small> - Reduces text size
  • <del> - Shows deleted/strikethrough text

Formatting Example

html

<p>This is <small>small text</small>.</p>
<p>This is <del>deleted text</del>.</p>

Combining Formatting Tags

You can nest formatting tags for combined effects:

Formatting Example

html

<p>This is <strong><em>bold and emphasized</em></strong> text.</p>

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE9+
YesYesYesYesYesYes

Conclusion

HTML formatting tags let you enhance the appearance and meaning of text on your page.
Use semantic tags like <strong> and <em> for important content, and visual tags like <b> or <i> for stylistic emphasis.