Home 〉 HTML Tutorials 〉 HTML Text Formatting Tags Explained with Examples - Complete Guide
HTML Text Formatting Tags Explained with Examples - Complete Guide !
What are HTML text formatting tags and how do they work?
HTML text formatting tags like '<b>', '<strong>', '<i>', '<em>', and '<mark>' allow developers to style and highlight parts of their web content. These tags are usually inline elements and are used for emphasizing, styling, or presenting content with specific meaning. This blog post covers each formatting tag, its syntax, usage, and styling. Also included are detailed examples and CSS styling tips. The complete blog post on HTML Text Formatting Tags is as follows.
In HTML, text formatting tags are used to style and emphasize parts of the text. These tags help structure content for readability and highlight important sections. Whether you're making text bold, italic, underlined, or highlighted, HTML formatting tags are essential for proper web content presentation.
These tags are mostly inline elements, meaning they do not break the layout or start a new line. In this tutorial, we'll explore all common HTML text formatting tags, their syntax, attributes, styling, and practical use cases.
Below is a list of frequently used HTML text formatting tags:
Tag | Description | Inline/Block/Empty |
---|---|---|
'<b>' | Makes text bold | Inline |
'<strong>' | Emphasizes importance with bold text | Inline |
'<i>' | Italicizes text | Inline |
'<em>' | Emphasizes with italics | Inline |
'<mark>' | Highlights text | Inline |
'<small>' | Reduces text size | Inline |
'<del>' | Displays deleted text | Inline |
'<ins>' | Displays inserted/underlined text | Inline |
'<sub>' | Subscript text | Inline |
'<sup>' | Superscript text | Inline |
'<u>' | Underlines text (deprecated in HTML5, use CSS instead) | Inline |
'<code>' | Displays code snippet | Inline |
'<pre>' | Preserves formatting and spaces | Block |
Syntax with Example:
output 📌
This is bold text
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Makes the text bold but without implying any special importance.
Example with CSS Styling:
<!DOCTYPE html>
<html>
<body>
<b style="font-size:16px; color:#222;">Bold Example</b>
</body>
</html>
output 📌
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Syntax with Example:
<!DOCTYPE html>
<html>
<body>
<p> This is a very <strong>Important message</strong></p?
</body>
</html>
output 📌
This is a very Important message
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Semantically emphasizes the text as important, also bolds it.
Example with CSS Styling:
<!DOCTYPE html>
<html>
<body>
<strong style="color: red;">Warning!</strong>
</body>
</html>
output 📌
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Syntax with Example:
output 📌
This is italic
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Renders text in italics with no semantic meaning.
Syntax with Example:
output 📌
This is emphasized
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Gives stress emphasis, and browsers render it as italic.
Syntax with Example:
<!DOCTYPE html>
<html>
<body>
<p>This is <mark>Highlighted text</mark></p>
</body>
</html>
output 📌
This is Highlighted text
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Highlights text like a marker.
Example with CSS Styling::
<!DOCTYPE html>
<html>
<body>
<mark style="background-color: yellow; padding:2px;">Notice</mark>
</body>
</html>
output 📌
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Syntax with Example:
<!DOCTYPE html>
<html>
<body>
<p>This is <small>Fine print text</small></p>
</body>
</html>
output 📌
This is Fine print text
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Decreases text size slightly.
Syntax with Example:
output 📌
This is removed text
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Displays text with a strikethrough line.
Syntax with Example:
<!DOCTYPE html>
<html>
<body>
<p>This inserts <ins>New content</ins></p>
</body>
</html>
output 📌
This inserts New content
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Underlines text and indicates it has been inserted.
Syntax with Example:
output 📌
Formula: H2O
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Lowers the text, often used in chemical formulas.
Syntax with Example:
output 📌
Formula: x2
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Raises the text, often used in math expressions.
Syntax with Example:
output 📌
This is Underlined text
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Underlines text, but it's not semantically meaningful. Prefer CSS.
Syntax with Example:
output 📌
let x = 5;
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Displays text in monospace font for code snippets.
Syntax with Example:
output 📌
Line 1 Line 2
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Preserves formatting, spaces, and line breaks.
These tags are inline, so you can use CSS properties like:
Example:
<!DOCTYPE html>
<html>
<body>
<b style="font-size:18px; color:blue;">Styled Bold Text</b>
</body>
</html>
output 📌
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
HTML text formatting tags help you control the visual appearance and semantic structure of your web content. Whether you want to bold, italicize, underline, highlight, or emphasize your text, these tags make it simple and effective. Proper use of these tags improves both readability and SEO performance.
'<b>' makes text bold without semantic meaning, while '<strong>' indicates importance semantically.
Yes, most formatting tags can be styled using inline or external CSS.
No, use CSS like 'text-decoration: underline;' for modern practices.
It is used to highlight text like with a marker.
Most formatting tags are inline-level.