Bold, Italic, Underline
- Bold Text (
<b>
and<strong>
):<b>
is used for stylistically bold text, while<strong>
indicates importance.
<b>Bold text</b>
<strong>Important text</strong>
- Italic Text (
<i>
and<em>
):<i>
is used for stylistic italicization, while<em>
emphasizes text.
<i>Italic text</i>
<em>Emphasized text</em>
- Underline Text (
<u>
):- Used to underline text.
<u>Underlined text</u>
Superscript and Subscript
- Superscript (
<sup>
):- Used to display text in a smaller font and half a character above the normal line.
H<sub>2</sub>O (Water)
- Subscript (
<sub>
):- Used to display text in a smaller font and half a character below the normal line.
E=mc<sup>2</sup> (Einstein's Mass-Energy Equivalence)
Text Alignment and Formatting
- Aligning Text (
<div>
or<p>
withstyle
attribute):- Use the
style
attribute to align text.
- Use the
<p style="text-align: center;">Center-aligned text</p>
<p style="text-align: right;">Right-aligned text</p>
Conclusion
Formatting text in HTML is a key skill for web design. It enhances the readability and appearance of web content. By mastering these tags and styles, you can create visually appealing and well-organized web pages.