Coding Coffee

Formatting Text in HTML

Bold, Italic, Underline

  1. Bold Text (<b> and <strong>):
    • <b> is used for stylistically bold text, while <strong> indicates importance.
<b>Bold text</b>
<strong>Important text</strong>
  1. Italic Text (<i> and <em>):
    • <i> is used for stylistic italicization, while <em> emphasizes text.
<i>Italic text</i>
<em>Emphasized text</em>
  1. Underline Text (<u>):
    • Used to underline text.
<u>Underlined text</u>

Superscript and Subscript

  1. Superscript (<sup>):
    • Used to display text in a smaller font and half a character above the normal line.
H<sub>2</sub>O (Water)
  1. 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> with style attribute):
    • Use the style attribute to align text.
<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.

Leave a Reply

Your email address will not be published. Required fields are marked *