HTML
📌 HTML Text Formatting
Overview
HTML provides special tags that allow you to display text not just as plain content, but with different visual and semantic styles. Using these tags, you can make text bold, italic, underlined, subscript, or superscript. Some tags are purely for visual effects, while others convey meaning and emphasize the importance of the text.
HTML Formatting Tags and Their Usage
| Tag | Meaning / Usage | Browser Display |
|---|---|---|
<b> |
Makes text bold without semantic importance | Appears bold only |
<strong> |
Marks text as important | Appears bold and screen readers emphasize it. |
<em> |
Emphasizes text semantically | Italic appearance with emphasis meaning |
<small> |
Displays smaller text | Shown in a smaller font size |
<del> |
Represents deleted or removed text | Displayed with a strikethrough |
<ins> |
Represents newly inserted text | Displayed with an underline |
<sub> |
Displays subscript text | Moves text down, useful for formulas or footnotes |
Guidelines for Using Tags
- Use
<b>and<i>for purely visual emphasis. - Use
<strong>and<em>when semantic meaning or content importance is required. - Use
<sub>and<sup>for chemical formulas, mathematical notations, or footnotes.
Examples
1. Bold Text
HTML
<b>This text is bold</b>
2. Strong Text
HTML
<strong>This text is important!</strong>
3. Italic Text
HTML
<i>This text is italic</i>
4. Emphasized Text
HTML
<em>This text is emphasized</em>
5. Small Text
HTML
<small>This is some smaller text.</small>
6. Marked / Highlighted Text
HTML
<p>Do not forget to buy <mark>milk</mark> today.</p>
7. Deleted Text
HTML
<p>My favorite color is <del>blue</del> red.</p>
8. Inserted Text
HTML
<p>My favorite color is <del>blue</del> <del>red.</del> </p>
9. Subscript Text
HTML
<p>My favorite color is <del>blue</del> <del>red.</del> </p>
10. Superscript Text
HTML
<p>My favorite color is <del>blue</del> <del>red.</del> </p>
