HTML Text Formatting
HTML text formatting elements are used to give meaning to text, not visual styling.
They help browsers, search engines, and screen readers understand how text should be interpreted.
Common Text Formatting Elements
<p>
This text is
<strong>important</strong>,
<em>emphasized</em>,
<mark>highlighted</mark>,
<small>smaller</small>,
<del>deleted</del>,
<ins>inserted</ins>,
and <u>underlined</u>.
</p>
Formatting Elements Explained
| Tag | Purpose |
|---|---|
<strong> | Important text |
<em> | Emphasized text |
<mark> | Highlighted text |
<small> | Smaller text |
<del> | Deleted text |
<ins> | Inserted text |
<u> | Underlined text |
Text Formatting with Attributes
Formatting elements support global attributes.
<strong
id="important-text"
class="highlight"
title="Important message">
Read this carefully
</strong>
Attributes Used
id→ unique identifierclass→ styling or groupingtitle→ tooltip text
Superscript and Subscript
<p>
H<sub>2</sub>O is water<br>
x<sup>2</sup> is a square value
</p>
Tags Used
<sub>→ subscript<sup>→ superscript
Important Notes
- Use formatting tags for meaning, not design
- Avoid overusing formatting elements
- Use CSS for visual styling
- Proper formatting improves accessibility