HTML Text Formatting

Welcome to the HTML Text Formatting tutorial on codeswithpankaj.com. In this tutorial, we will explore different HTML text formatting tags, why they are important, and provide examples to help you understand how to use them effectively.

What is HTML Text Formatting?

HTML text formatting is used to change the appearance of text in HTML documents. These tags allow you to emphasize, style, and structure text to improve readability and presentation.

Common HTML Text Formatting Tags

1. <b> - Bold Text

The <b> tag is used to make text bold. It is typically used for drawing attention to text without implying importance.

Example:

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

2. <strong> - Important Text

The <strong> tag is used to indicate that the text is of strong importance. It is typically rendered in bold.

Example:

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

3. <i> - Italic Text

The <i> tag is used to italicize text. It is often used for technical terms, foreign words, or other text that needs to be distinguished from normal text.

Example:

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

4. <em> - Emphasized Text

The <em> tag is used to emphasize text. It is typically rendered in italic.

Example:

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

5. <u> - Underlined Text

The <u> tag is used to underline text. It is often used to denote misspelled words or for stylistic purposes.

Example:

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

6. <mark> - Marked Text

The <mark> tag is used to highlight text. It is often rendered with a yellow background.

Example:

<p>This is <mark>highlighted</mark> text.</p>

7. <small> - Smaller Text

The <small> tag is used to render text in a smaller font size.

Example:

<p>This is <small>smaller</small> text.</p>

8. <del> - Deleted Text

The <del> tag is used to show text that has been deleted. It is typically rendered with a strikethrough.

Example:

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

9. <ins> - Inserted Text

The <ins> tag is used to show text that has been inserted. It is typically rendered with an underline.

Example:

<p>This is <ins>inserted</ins> text.</p>

10. <sub> - Subscript Text

The <sub> tag is used to create subscript text.

Example:

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

11. <sup> - Superscript Text

The <sup> tag is used to create superscript text.

Example:

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

Practical Examples

Here are some practical examples of how to use text formatting tags to enhance your web pages.

Example 1: Article Content

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HTML Text Formatting - codeswithpankaj.com</title>
</head>
<body>
    <h1>Understanding HTML Text Formatting</h1>
    <p>In this article, we will explore various HTML text formatting tags and their uses.</p>
    <h2>Bold and Important Text</h2>
    <p>You can use the <code>&lt;b&gt;</code> tag to make text <b>bold</b> and the <code>&lt;strong&gt;</code> tag to indicate <strong>important</strong> text.</p>
    <h2>Italic and Emphasized Text</h2>
    <p>The <code>&lt;i&gt;</code> tag is used for <i>italic</i> text, while the <code>&lt;em&gt;</code> tag is used for <em>emphasized</em> text.</p>
    <h2>Underlined and Highlighted Text</h2>
    <p>To underline text, use the <code>&lt;u&gt;</code> tag: <u>underlined</u>. To highlight text, use the <code>&lt;mark&gt;</code> tag: <mark>highlighted</mark>.</p>
</body>
</html>

Example 2: Technical Document

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Technical Document - HTML Text Formatting</title>
</head>
<body>
    <h1>HTML Text Formatting in Technical Documents</h1>
    <p>In technical documents, it's important to use proper text formatting to convey information clearly.</p>
    <h2>Example Usage</h2>
    <p>For instance, <strong>critical</strong> updates should be bold, while <em>technical terms</em> can be italicized.</p>
    <p>Superscripts are used for references<sup>1</sup> and subscripts for chemical formulas like H<sub>2</sub>O.</p>
</body>
</html>

Conclusion

HTML text formatting tags are essential for enhancing the readability and presentation of your content. By using these tags effectively, you can create more engaging and informative web pages. Stay tuned to codeswithpankaj.com for more tutorials and web development tips!

Last updated