Logo OnlineCBT
HTML Tutorial
HTML · LESSON 11

Text Formatting Tags

Format text using semantic and visual tags like strong, em, mark, sub, sup, and small.

Level: Beginner to Advanced
Duration: ~60 Mins Deep-Dive
Updated: 30 Jul 2026

Text Formatting Tags

1. Semantic Importance vs. Presentational Tags

In early HTML specifications, tags were often used purely to alter text appearances—such as making text bold using <b> or italic using <i>. Modern web development enforces a strict separation: **HTML conveys semantic meaning, while CSS handles visual presentation.**

HTML5 introduced semantic formatting tags like <strong> and <em>. While they render as bold and italic visually by default, their primary purpose is to inform search engines and assistive screen readers about the structural weight or verbal emphasis of the text.

HTML Tag Type Category Semantic Meaning & Screen Reader Impact
<strong> Semantic Importance Indicates high topic importance or urgency. Screen readers change tone/pitch to reflect gravity.
<b> Presentational Bold Draws visual attention without adding semantic importance (e.g. keywords in a summary, product names).
<em> Semantic Emphasis Marks stress emphasis. Alters sentence context or spoken verbal stress in screen readers.
<i> Presentational Italic Represents an alternate voice, technical terms, foreign phrases, or ship names without added stress.
<!-- Strong vs Bold and Emphasis vs Italic -->
<p><strong>Warning:</strong> Always back up your data before proceeding.</p>
<p>The term <b>CSS</b> stands for Cascading Style Sheets.</p>

<p>I <em>love</em> web development!</p>
<p>The Latin phrase <i>carpe diem</i> translates to seize the day.</p>
Hardcoded Output Result (Rendered View in White Box) //
//

Warning: Always back up your data before proceeding.

//

The term CSS stands for Cascading Style Sheets.

//

I love web development!

//

The Latin phrase carpe diem translates to seize the day.

//

2. Subscripts (<sub>) and Superscripts (<sup>)

When displaying mathematical equations, chemical formulas, dates, or footnotes, standard font baselines need to shift vertically.

  • <sub> (Subscript): Lowers text slightly below the standard baseline and renders it in a smaller font size. Used primarily in chemical formulas (like H2O) or variable indices (X1).
  • <sup> (Superscript): Raises text slightly above the standard baseline and renders it in a smaller font size. Used for mathematical exponents (E = mc2), ordinal numbers (1st, 2nd), or footnote references.
<!-- Chemical Formulas & Mathematical Exponents -->
<p>Water is represented chemically as H<sub>2</sub>O.</p>
<p>Glucose chemical formula: C<sub>6</sub>H<sub>12</sub>O<sub>6</sub>.</p>

<p>Pythagorean Theorem: a<sup>2</sup> + b<sup>2</sup> = c<sup>2</sup>.</p>
<p>He finished in 1<sup>st></sup> place on July 30<sup>th></sup>.</p>
Hardcoded Output Result (Rendered View in White Box)

Water is represented chemically as H2O.

Glucose chemical formula: C6H12O6.

Pythagorean Theorem: a2 + b2 = c2.

He finished in 1st place on July 30th.

3. Highlighting and Document Revisions (<mark>, <del>, <ins>, <s>, <u>)

HTML provides dedicated inline tags to track document revisions, price updates, text highlights, or invalid content.

  • <mark>: Represents text highlighted for reference or search result matching (renders with a yellow background by default).
  • <del>: Represents deleted or removed text during document editing (renders with a strikethrough line).
  • <ins>: Represents newly inserted text added during revisions (renders with an underline). Used alongside <del>.
  • <s>: Represents content that is no longer accurate or relevant (e.g. old product prices), but not strictly deleted from document history.
  • <u>: Unarticulated annotation (underline). Used for spelling errors or proper nouns in Chinese text. Avoid using for regular text to prevent confusion with hyperlinked text.
<!-- Revisions & Highlights Example -->
<p>Search Result: Found 10 matches for <mark>HTML5</mark>.</p>

<p>Discount Sale: Price <del>$99.99</del> <ins>$49.99</ins>!</p>
<p>Special Offer: <s>Free shipping available</s> (Expired).</p>
Hardcoded Output Result (Rendered View in White Box)

Search Result: Found 10 matches for HTML5.

Discount Sale: Price $99.99 $49.99!

Special Offer: Free shipping available (Expired).

4. Technical Formatting (<code>, <kbd>, <samp>, <small>)

When documenting software, technical instructions, or legal disclaimers, specialized inline tags provide appropriate semantic styling.

  • <code>: Formats short fragments of computer code inline using a monospace font.
  • <kbd>: Represents keyboard input or keystrokes entered by a user (e.g., Ctrl + C).
  • <samp>: Represents sample output outputted by a computer program or system console.
  • <small>: Represents side comments, fine print, copyright statements, or legal disclosures (renders 1 size smaller).
<!-- Technical Instructions & Disclaimers -->
<p>To save your file in VS Code, press <kbd>Ctrl</kbd> + <kbd>S</kbd>.</p>
<p>Use the <code>&lt;div&gt;</code> element to group block content.</p>
<p>Server Output: <samp>200 OK Connection Established</samp>.</p>

<footer>
    <p><small>&copy; 2026 Developer Portal. Terms and conditions apply.</small></p>
</footer>
Hardcoded Output Result (Rendered View in White Box)

To save your file in VS Code, press Ctrl + S.

Use the

element to group block content.

Server Output: 200 OK Connection Established.

© 2026 Developer Portal. Terms and conditions apply.

5. Homework Assignments & Practical Exercises

Task 1: Scientific & Math Expression Page (Current Lesson)

Create a formulas.html page. Write chemical formulas for Water (H2O), Carbon Dioxide (CO2), and Sulphuric Acid (H2SO4) using <sub>. Write mathematical expressions for E=mc2 and x3 + y3 using <sup>.

Task 2: E-Commerce Product Card Revisions (Current Lesson)

Construct a product sales block. Display an original price marked with <del> ($120.00) next to a sale price marked with <ins> ($79.99). Highlight the phrase "50% OFF" using <mark>, and place copyright disclaimers at the bottom using <small>.

Task 3: Full Developer Cheat-Sheet Audit (All-Inclusive Task)

Combine learnings from Lessons 01 through 11: Create a keyboard shortcuts cheat-sheet for VS Code using <kbd>, <code>, and <strong> tags. Validate your code through validator.w3.org and confirm that screen readers announce semantic importance correctly.

6. Frequently Asked Interview Questions

Q1: What is the semantic difference between <strong> and <b>?

Answer: The <strong> element represents semantic importance, seriousness, or urgency, prompting screen readers to alter tone or inflection. The <b> element is purely presentational, drawing visual bold attention to text without implying additional importance or accessibility cues.

Q2: Why should developers avoid using the <u> (underline) tag for standard text emphasis?

Answer: On the web, underlined text is universally recognized as an active hyperlink. Using <u> on non-clickable text confuses users who try to click it. Use <em> or <strong> for emphasis instead.

Q3: How do <del> and <ins> tags improve document accessibility for revision tracking?

Answer: The <del> (deletion) and <ins> (insertion) tags inform screen readers and document difference tools that specific text was removed or added during an edit. Screen readers explicitly announce "deleted text" and "inserted text" to visually impaired users.

Q4: What is the primary purpose of the <kbd> tag in technical documentation?

Answer: The <kbd> tag semantically identifies user keyboard inputs, voice commands, or key combinations (like Ctrl + S). Browser default stylesheets render it in monospace font, and custom CSS can style it to resemble physical keyboard keys.

Next Lesson: Quotations and Citations

Now that you master inline text formatting and revision tags, our next lesson explores semantic citations and quotes:

  • Block Quotes (<blockquote>): Formatting multi-line external quotes with indentation and citation URLs.
  • Inline Quotes (<q>): Handling automatic localized quotation marks for short inline quotes.
  • Citations (<cite>): Marking work titles, book titles, research papers, and creative works.
  • Abbreviations (<abbr>) and Contact Addresses (<address>): Structuring acronym tooltips and author contact metadata.

📝 Live Lesson Practice

HTML/CSS JavaScript Python C++ C PHP
⌨️ Practice Inputs (लाइव इनपुट भरें) (खाली होने पर RED, भरने पर GREEN underline)
💻 Code Editor (Monaco VS Code Engine)
👀 Live Preview
Address Contact

+91 7877547686

E-mail

onlinecbtportal@gmail.com

Helpline Number

+91 7877547686


Click To Download
Get it on Google Play

ऐप डाउनलोड करने
के लिए Google Play पर
उपलब्ध है

WhatsApp Chat