Table of Content
Enhance your web pages with proper text formatting using HTML tags and attributes. Imagine a plain white paper with just words written on it. Now think of a colorful paper with different-sized, bold, and underlined words, highlighted paragraphs, and maybe even pictures. HTML text formatting is like that colorful paper. It adds styles to your text to make it more visually appealing and easier to read.
Here's an example of plain text vs. formatted text:
The quick brown fox jumped over the lazy dog.
Animal Antics
The quick, brown fox jumped over the lazy dog.
As you can see, the formatted text is more structured, emphasized, and visually engaging.
The HTML <b> element makes text bold, highlighting important words or phrases within a text.
<!DOCTYPE html>
<html>
<head>
<title>HTML Bold Example</title>
</head>
<body>
<p>This is a normal paragraph.</p>
<p>This is a paragraph with <b>bold text</b> to highlight important information.</p>
</body>
</html>
Example Explanation
In this example, the <b> tag is used to make "bold text" stand out from the rest of the paragraph.
The HTML <strong> element indicates strong importance, rendering the text in bold and emphasizing its significance.
<!DOCTYPE html>
<html>
<head>
<title>HTML Strong Example</title>
</head>
<body>
<p>This is a normal paragraph.</p>
<p>This is a paragraph with <strong>strong text</strong> to emphasize important information.</p>
</body>
</html>
Example Explanation
In this example, the <strong> tag is used to make "strong text" stand out and signify its importance.
While both the <strong> and <b> tags render text in bold, they serve different purposes. The <b> tag is used purely for visual styling, making text bold without conveying any extra meaning. The <strong> tag, on the other hand, indicates that the text is of strong importance or urgency, adding semantic meaning to the bold text.
The HTML <i> element makes text italic, typically used to denote a different tone or style, such as foreign words, technical terms, or names of ships.
<!DOCTYPE html>
<html>
<head>
<title>HTML Italic Example</title>
</head>
<body>
<p>This is a normal paragraph.</p>
<p>This is a paragraph with <i>italic text</i> to denote a different tone or style.</p>
</body>
</html>
Example Explanation
In this example, the <i> tag is used to make "italic text" stand out and denote a different tone or style.
The HTML <em> element emphasizes text, typically rendering it in italic and conveying a change in meaning or importance.
<!DOCTYPE html>
<html>
<head>
<title>HTML Emphasis Example</title>
</head>
<body>
<p>This is a normal paragraph.</p>
<p>This is a paragraph with <em>emphasized text</em> to convey importance.</p>
</body>
</html>
Example Explanation
In this example, the <em> tag is used to make "emphasized text" stand out and convey importance.
While both the <i> and <em> tags render text in italic, they serve different purposes. The <i> tag is used for visual styling to denote a different tone or style. The <em> tag, however, conveys semantic emphasis, indicating that the text is of particular importance or carries a different meaning.
The HTML <u> element underlines text, typically used to denote misspelled words or to bring attention to specific text.
<!DOCTYPE html>
<html>
<head>
<title>HTML Underline Example</title>
</head>
<body>
<p>This is a normal paragraph.</p>
<p>This is a paragraph with <u>underlined text</u> to denote special attention.</p>
</body>
</html>
Example Explanation
In this example, the <u> tag is used to make "underlined text" stand out and denote special attention.
The HTML <strike> element draws a line through the text, indicating that it is no longer relevant or accurate.
<!DOCTYPE html>
<html>
<head>
<title>HTML Strikethrough Example</title>
</head>
<body>
<p>This is a normal paragraph.</p>
<p>This is a paragraph with <strike>strikethrough text</strike> to indicate it is outdated.</p>
</body>
</html>
Example Explanation
In this example, the <strike> tag is used to make "strikethrough text" stand out, indicating that it is outdated or no longer relevant.
The HTML <sup> element raises text slightly above the baseline, often used for footnotes, mathematical expressions, or ordinal indicators.
<!DOCTYPE html>
<html>
<head>
<title>HTML Superscript Example</title>
</head>
<body>
<p>This is a normal paragraph.</p>
<p>This is a paragraph with 10<sup>2</sup> to represent 10 squared.</p>
</body>
</html>
Example Explanation
In this example, the <sup> tag is used to raise "2" slightly above the baseline to represent "10 squared".
The HTML <sub> element lowers text slightly below the baseline, often used in chemical formulas or mathematical expressions.
<!DOCTYPE html>
<html>
<head>
<title>HTML Subscript Example</title>
</head>
<body>
<p>This is a normal paragraph.</p>
<p>This is a paragraph with H<sub>2</sub>O to represent the chemical formula for water.</p>
</body>
</html>
Example Explanation
In this example, the <sub> tag is used to lower "2" slightly below the baseline to represent the chemical formula for water.
The HTML <ins> element indicates text that has been inserted into a document, typically rendered with an underline.
<!DOCTYPE html>
<html>
<head>
<title>HTML Inserted Text Example</title>
</head>
<body>
<p>This is a normal paragraph.</p>
<p>This is a paragraph with <ins>inserted text</ins> to indicate new additions.</p>
</body>
</html>
Example Explanation
In this example, the <ins> tag is used to underline "inserted text" to indicate new additions.
The HTML <mark> element highlights text with a background color, indicating it is particularly relevant or important.
<!DOCTYPE html>
<html>
<head>
<title>HTML Marked Text Example</title>
</head>
<body>
<p>This is a normal paragraph.</p>
<p>This is a paragraph with <mark>highlighted text</mark> to indicate its importance.</p>
</body>
</html>
Example Explanation
In this example, the <mark> tag is used to highlight "highlighted text" with a background color to indicate its importance.
How do I create a block of preformatted text?
What are physical and logical text formatting tags in HTML?
Can I combine multiple text formatting tags?
What is the <code> tag used for?
What is HTML text formatting?
What are the text formatting tags in HTML?
How to keep text formatting in HTML?
How to change text style in HTML?
एचटीएमएल टेक्स्ट फॉर्मेटिंग क्या है?
What is text formatting explain?
What is HTML text used for?
How to auto format HTML?
What are HTML Formatting tags?
How do you format text in HTML?