HTML Formatting
Formatting elements give text extra meaning, such as importance or emphasis.
The browser usually shows formatting elements in bold or italics, but the meaning they carry matters more than the look. Screen readers can announce that meaning to users.
Common Formatting Elements
Importance and Emphasis
strong and em
<!DOCTYPE html>
<html>
<body>
<p>This is <strong>important</strong> and this is <em>emphasized</em>.</p>
</body>
</html>Subscript and Superscript
sub and sup
<!DOCTYPE html>
<html>
<body>
<p>H<sub>2</sub>O and E = mc<sup>2</sup></p>
</body>
</html>Note: Prefer <strong> and <em> over <b> and <i>. They carry meaning, not just a visual style.
Exercise: HTML Formatting
What is the key difference between <strong> and <b> for emphasizing text?