Skip to main content
Syllabus

HTML Text Formatting (Bold, Italic, Mark, etc.)

Badar KhalilUpdated September 27, 2026 1 min read

HTML Text Formatting (Bold, Italic, Mark, etc.)

HTML text formatting elements let you emphasize, highlight, and style text directly within your content. A key modern best practice is understanding the difference between semantic formatting (which conveys meaning) and purely visual formatting (which just changes appearance).

Bold Text: <strong> vs <b>

  • <strong> — indicates text of strong importance (semantic). Screen readers may announce it differently.
  • <b> — simply makes text bold visually, with no added semantic meaning.
Code
<p><strong>Warning:</strong> This action cannot be undone.</p>
<p>The <b>Titanic</b> sank in 1912.</p>

Italic Text: <em> vs <i>

  • <em> — adds emphasis (semantic), often changing the meaning of a sentence.
  • <i> — italicizes text visually (e.g., for technical terms or foreign words), without semantic emphasis.
Code
<p>I <em>really</em> need you to read this.</p>
<p>The term <i>habeas corpus</i> is Latin.</p>

Highlighting Text with <mark>

The <mark> tag highlights text with a default yellow background — commonly used for search result highlighting:

Code
<p>Search results for <mark>HTML tutorials</mark> found 42 matches.</p>

Other Useful Formatting Elements

  • <small> — represents side comments or fine print
  • <del> — represents deleted/removed text (shown with strikethrough)
  • <ins> — represents inserted text (shown underlined)
  • <sub> — subscript text (e.g., chemical formulas)
  • <sup> — superscript text (e.g., footnotes, exponents)
Code
<p>Price: <del>$50</del> <ins>$35</ins></p>
<p>Water is H<sub>2</sub>O</p>
<p>E = mc<sup>2</sup></p>

Semantic HTML: Why It Matters More in 2026

Using semantic formatting tags like <strong> and <em> instead of purely visual tags improves accessibility for screen reader users and gives search engines better context about which words matter most in your content.

Key Takeaways

  • <strong>/<em> add semantic meaning; <b>/<i> are purely visual.
  • <mark> highlights text, commonly used for search matches.
  • <del>/<ins> show removed/added content; <sub>/<sup> handle subscript/superscript text.
  • Prefer semantic tags for better accessibility and SEO.
Try it Yourself HTML
Output

Press Run to execute.

Exercise: Apply Correct Semantic FormattingHTML

Rewrite the sentence 'Warning this is very important and the word urgent must be emphasized' using strong for 'Warning' and em for 'urgent'.

Try it Yourself HTML
Output

Press Run to execute.

This is a self-check — compare your result with the expected output above.

Was this page helpful?