HTML Basics
HTML Text Formatting
HTML has a set of tags for emphasising and styling text. Some carry real meaning, like importance and emphasis, while others are purely visual — knowing the difference matters.
What is HTML Text Formatting?
Text formatting tags change how words look and, in some cases, what they mean. For example, <strong> makes text bold and tells browsers the text is important, while <b> only makes text bold with no added meaning.
Preferring the meaningful tags — <strong> and <em> over <b> and <i> — helps search engines and screen readers understand your content. Both look the same, but only one conveys intent.
Basic Usage
<p><strong>Warning:</strong> this action <em>cannot</em> be undone.</p>Example: All the Common Formatting Tags
<!DOCTYPE html>
<html>
<body>
<p><b>Bold</b> and <strong>important</strong> text.</p>
<p><i>Italic</i> and <em>emphasised</em> text.</p>
<p><mark>Highlighted</mark> and <small>small</small> text.</p>
<p><del>Deleted</del> and <ins>inserted</ins> text.</p>
<p>H<sub>2</sub>O and E = mc<sup>2</sup></p>
</body>
</html>More Examples
<p>Course price: <del>$99</del> <strong>$49</strong> today only!</p><p>Water is H<sub>2</sub>O.</p>
<p>The area is 10 cm<sup>2</sup>.</p>Formatting Tags Reference
| Tag | Renders as | Meaning |
|---|---|---|
| <strong> | Bold | Important content |
| <b> | Bold | Stylistic bold, no meaning |
| <em> | Italic | Emphasised content |
| <i> | Italic | Stylistic italic, no meaning |
| <mark> | Highlighted | Relevant / highlighted text |
| <small> | Smaller | Fine print, side notes |
| <del> | Strikethrough | Removed text |
| <ins> | Underline | Added text |
Prefer <strong> and <em> over <b> and <i> when the text truly is important or emphasised. They mean the same visually but carry semantics for accessibility and SEO.
Do not use text formatting tags to build layout or to fake headings. Use headings for titles and CSS for visual styling.
Key Takeaways
- <strong> and <em> add meaning; <b> and <i> are purely visual.
- <mark> highlights, <small> shrinks, <del> and <ins> show edits.
- <sub> and <sup> handle subscripts and superscripts.
- Choose tags by meaning first, then style with CSS.
