Skip to content

Text Formatting in HTML

Text formatting tags in HTML are used to modify the appearance of text within a web page, allowing developers to apply various styles such as bold, italic, underline, and more. These tags provide a way to structure and enhance the visual presentation of content without the need for CSS (Cascading Style Sheets). Here are some commonly used text formatting tags in HTML:

1. Bold Text (<b> or <strong>): The <b> and <strong> elements are used to make text bold. While both tags visually render text in bold, the <strong> element is semantically stronger and is typically used to emphasize important content.

Example:

<p>This is <b>bold</b> text.</p>

<p>This is <strong>strong</strong> text.</p>

2. Italic Text (<i> or <em>): The <i> and <em> elements are used to italicize text. Similar to the <b> and <strong> elements, both tags render text in italics, but the <em> element is semantically emphasized and is used to denote emphasis.

Example:

<p>This is <i>italic</i> text.</p>

 <p>This is <em>emphasized</em> text.</p>

3. Underline Text (<u>): The <u> element is used to underline text. It visually decorates the text with a line underneath, indicating emphasis or importance. However, it is worth noting that underlined text is less common in modern web design due to its association with hyperlinks.

Example:

<p>This is <u>underlined</u> text.</p>

4. Strikethrough Text (<s> or <strike> or <del>): The <s>, <strike>, and <del> elements are used to apply a strikethrough effect to text, indicating that it has been deleted or is no longer relevant. These tags are commonly used in contexts such as revision history or to mark outdated information.

Example:

<p>This is <s>strikethrough</s> text.</p>

<p>This is <strike>strikethrough</strike> text.</p>

<p>This is <del>strikethrough</del> text.</p>

5. Superscript Text (<sup>) and Subscript Text (<sub>): The <sup> and <sub> elements are used to render text in superscript and subscript, respectively. Superscript text appears above the baseline, while subscript text appears below the baseline.

Example:

<p>This is <sup>superscript</sup> text.</p>

<p>This is <sub>subscript</sub> text.</p>

These are just a few examples of text formatting tags in HTML. While these tags provide basic styling options, it’s essential to use them judiciously and consider their semantic meaning when structuring content. Additionally, for more advanced styling and customization, CSS should be used to separate content from presentation.