🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
HTML MASTER CLASS /// LEARN TAGS /// BUILD STRUCTURE /// SEMANTIC WEB /// HTML MASTER CLASS /// LEARN TAGS ///

HTML Text Formatting

Learn about Text Formatting in this comprehensive HTML5 web development tutorial. Learn to distinguish between visual and semantic formatting. Master the use of strong, em, code, and mark tags to create accessible and technically sound text blocks.

Narrated Video Summary
data-composition-id="html-html-text-formatting"1280×720 @ 30fps10 clips4:25 total

Introduction to Semantic Formatting

Formatting text in modern web development is not merely about visual aesthetics; it is about conveying structural emphasis and meaning. While CSS should always be used to handle how things 'look', HTML provides specialized tags to give your text extra semantic weight. These Semantic Text Modifiers ensure that your content is not only visually distinct on the screen but also programmatically meaningful to screen readers and search engine indexing algorithms.

Importance and Emphasis

Historically, developers used `<b>` (bold) and `<i>` (italic) to format text. However, these tags are purely visual. Modern architecture dictates the use of `<strong>` and `<em>`. The `<strong>` tag indicates that a piece of text has critical, urgent importance. The `<em>` tag indicates 'stress emphasis', subtly altering the meaning of a sentence just as vocal inflection would. Screen readers actually change their audible intonation when they encounter these specific semantic markers.

Technical Code Snippets

When documenting technical instructions, you must differentiate conversational prose from actionable code. The `<code>` tag is designed specifically for this. It informs the browser that the enclosed text represents a fragment of computer code. By default, browsers will render this using a monospace typeface (like Courier), creating an immediate, universally recognized visual distinction between the standard paragraph text and the technical command the user needs to execute.

Visual Highlighting with Mark

The `<mark>` tag represents text that has been highlighted for reference or relevance in another context—much like using a yellow highlighter pen in a physical textbook. This tag is exceptionally useful when building search interfaces, allowing you to dynamically highlight the specific search term within a larger block of returned results, immediately drawing the user's eye to the relevant data payload.

Documenting Deleted Text

Sometimes you need to show that information has been removed or updated without completely erasing it from the page, such as a price drop or a corrected spelling. For this, HTML provides the `<del>` (deleted) tag. When the browser encounters `<del>`, it natively applies a visual strikethrough effect. More importantly, it programmatically informs screen readers and search engines that this specific data is no longer accurate.

Documenting Inserted Text

Working as the counterpart to `<del>`, the `<ins>` (inserted) tag is used to denote text that has been newly added to a document. This is highly useful in wikis, edit histories, or when tracking changes over time. By default, browsers will render `<ins>` text with an underline. By pairing `<del>` and `<ins>`, you create a semantically rich log of document revisions that both humans and automated bots can understand.

Quoting and Citation

When citing external sources or presenting long quotations, the `<blockquote>` element provides both semantic meaning and a distinct visual presentation. It indicates to the browser and assistive technologies that the enclosed text is an extended quotation. For shorter, inline quotes within a standard paragraph, you should use the `<q>` tag instead. Browsers natively handle the visual formatting for both, indenting blockquotes and adding quotation marks to inline quotes.

Text Formatting Mastered

Text formatting mastery is officially complete! You have elevated your markup from purely visual decoration to rich, semantic architecture. By utilizing `<strong>`, `<em>`, `<code>`, and `<mark>`, you ensure that your content is highly accessible, machine-readable, and structurally precise. Up next, we will explore 'HTML Lists'—the primary tools for organizing related data into logical, readable sequences.

Up Next: Data Organization

With our text semantically formatted, we must now learn how to structure grouped information. In our next module, we will master HTML Lists. We will explore unordered structures, sequential ordered logic, and how to nest these tags to build complex, professional document hierarchies and navigation menus.

0:00 / 4:25
Scene 1 / 10 — Introduction to Semantic Formatting
Total XP: 0|💻 html XP: 0

Skill Matrix

UNLOCK NODES BY LEARNING NEW TAGS.

Formatting Node

Semantic Emphasis.


🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.

HTML isn't just about the words; it's about the weight you give them. Mastering semantic formatting ensures your message is clear to both humans and machines.

1Semantic Weight vs. Visual Style

Historically, developers used the <b> (bold) and <i> (italic) tags to format text. However, these tags are purely visual—they tell the browser how to render the text, but they convey zero meaning to assistive technologies or search engines.

Modern web architecture demands semantic rigor. Instead of <b>, you must use the <strong> tag to indicate that a piece of text has critical, urgent importance. Instead of <i>, use the <em> tag to indicate stress emphasis. Screen readers actively change their vocal intonation when they encounter these tags. Using semantic formatting is the difference between a page that merely looks right and a page that actually works for all users.

+
<!-- Semantic Importance -->
<p>
  <strong>Warning:</strong> Do <em>not</em> reboot.
</p>
localhost:3000
Browser Output

Warning: Do not reboot.

2Technical and Contextual Formatting

When documenting software or referencing specific data, you need specialized modifiers. The <code> tag is explicitly designed to distinguish actionable computer code from conversational prose. The browser will natively render this using a monospace typeface.

Additionally, the <mark> tag is used to highlight text for contextual relevance—imagine using a yellow highlighter in a textbook. This is aggressively used in search interfaces to instantly draw the user's eye to their query term within a large block of text. These tags provide immediate clarity without forcing you to write complex CSS.

+
<p>Run <code>npm install</code>.</p>
<p>Result: <mark>Success</mark>.</p>
localhost:3000
Browser Output

Run npm install.

Result: Success.

3Document Tracking and Citations

When data changes, you shouldn't just delete the old text. By using the <del> (deleted) and <ins> (inserted) tags, you programmatically document the revision history of the page. Browsers natively strike through the deleted text and underline the inserted text, providing instant transparency for price drops or corrected information.

Similarly, when importing external data, the <blockquote> element is mandatory for extended quotations. It explicitly links the borrowed text to a source and structurally distances it from your own prose.

+
<p>Price: <del>$50</del> <ins>$40</ins></p>

<blockquote>
  Data is the new oil.
</blockquote>
localhost:3000
Browser Output

Price: $50 $40

Data is the new oil.

4Step-by-Step Breakdown

Introduction to Semantic Formatting. Formatting text in modern web development is not merely about visual aesthetics; it is about conveying structural emphasis and meaning. While CSS should always be used to handle how things 'look', HTML provides specialized tags to give your text extra semantic weight. These Semantic Text Modifiers ensure that your content is not only visually distinct on the screen but also programmatically meaningful to screen readers and search engine indexing algorithms.

Importance and Emphasis. Historically, developers used <b> (bold) and <i> (italic) to format text. However, these tags are purely visual. Modern architecture dictates the use of <strong> and <em>. The <strong> tag indicates that a piece of text has critical, urgent importance. The <em> tag indicates 'stress emphasis', subtly altering the meaning of a sentence just as vocal inflection would. Screen readers actually change their audible intonation when they encounter these specific semantic markers.

Checkpoint: Accessibility is a core responsibility for developers. If you have a warning label that requires 'critical importance' and needs to be forcefully announced by assistive technologies, which semantic tag should you use instead of the purely visual <b> tag?

  • <b>
  • <em>
  • <strong>
  • <important>

Technical Code Snippets. When documenting technical instructions, you must differentiate conversational prose from actionable code. The <code> tag is designed specifically for this. It informs the browser that the enclosed text represents a fragment of computer code. By default, browsers will render this using a monospace typeface (like Courier), creating an immediate, universally recognized visual distinction between the standard paragraph text and the technical command the user needs to execute.

Visual Highlighting with Mark. The <mark> tag represents text that has been highlighted for reference or relevance in another context—much like using a yellow highlighter pen in a physical textbook. This tag is exceptionally useful when building search interfaces, allowing you to dynamically highlight the specific search term within a larger block of returned results, immediately drawing the user's eye to the relevant data payload.

Checkpoint: It is important to know the difference between structural importance and vocal stress. True or False? The <em> tag is used to add 'stress emphasis' to a word, which structurally alters the precise meaning of a sentence, and is typically rendered by browsers in italics.

  • True (It alters vocal stress)
  • False (It is only for visual italics)

Documenting Deleted Text. Sometimes you need to show that information has been removed or updated without completely erasing it from the page, such as a price drop or a corrected spelling. For this, HTML provides the <del> (deleted) tag. When the browser encounters <del>, it natively applies a visual strikethrough effect. More importantly, it programmatically informs screen readers and search engines that this specific data is no longer accurate.

Documenting Inserted Text. Working as the counterpart to <del>, the <ins> (inserted) tag is used to denote text that has been newly added to a document. This is highly useful in wikis, edit histories, or when tracking changes over time. By default, browsers will render <ins> text with an underline. By pairing <del> and <ins>, you create a semantically rich log of document revisions that both humans and automated bots can understand.

Checkpoint: If you are building an e-commerce site and want to show the original price of an item crossed out because it is on sale, which semantic tag should you use to indicate that the old price is no longer valid?

  • <del>
  • <strike>
  • <s>
  • <old>

Quoting and Citation. When citing external sources or presenting long quotations, the <blockquote> element provides both semantic meaning and a distinct visual presentation. It indicates to the browser and assistive technologies that the enclosed text is an extended quotation. For shorter, inline quotes within a standard paragraph, you should use the <q> tag instead. Browsers natively handle the visual formatting for both, indenting blockquotes and adding quotation marks to inline quotes.

Checkpoint: What semantic tag should you use to enclose a long quotation that needs to be visually set apart from the surrounding text?

  • <blockquote>
  • <q>
  • <cite>
  • <quote>

Text Formatting Mastered. Text formatting mastery is officially complete! You have elevated your markup from purely visual decoration to rich, semantic architecture. By utilizing <strong>, <em>, <code>, and <mark>, you ensure that your content is highly accessible, machine-readable, and structurally precise. Up next, we will explore 'HTML Lists'—the primary tools for organizing related data into logical, readable sequences.

Up Next: Data Organization. With our text semantically formatted, we must now learn how to structure grouped information. In our next module, we will master HTML Lists. We will explore unordered structures, sequential ordered logic, and how to nest these tags to build complex, professional document hierarchies and navigation menus.

Add Semantic Emphasis. <strong> marks strong importance; <em> marks stressed emphasis — both carry real semantic meaning.

Level Up 🚀

Advanced cheat sheets, SEO tricks, and interview prep for this topic.

Browser Support

ChromeSupported

Fully supported.

FirefoxSupported

Fully supported.

SafariSupported

Fully supported.

EdgeSupported

Fully supported.

Accessibility (A11y)

1`<strong>` and `<em>` Change Screen Reader Prosody

Unlike `<b>` and `<i>`, which are purely visual, `<strong>` and `<em>` are announced with altered vocal stress by most screen readers (VoiceOver and NVDA in particular). Using `<b>` for a warning that must be heard as urgent silently fails blind users even though it looks identical sighted.

<p><strong>Warning:</strong> this action cannot be undone.</p>

2`<mark>` Needs Context, Not Just Color

`<mark>` conveys 'relevant in this context' (like a search-term match), but screen readers announce it inconsistently across engines — some say 'highlighted', others say nothing at all. For critical information, don't rely on `<mark>` alone; add surrounding text or `aria-label` that states why the text matters.

SEO Implications

  • 1

    `<strong>` Carries Minor On-Page Weight, `<b>` Carries None

    Search engines treat `<strong>`/`<em>` as a weak relevance signal for the wrapped keywords, similar to how they weigh headings, but with far less influence. `<b>` and `<i>` are purely presentational and are not used as a ranking or relevance signal at all.

  • 2

    `<cite>` and `<blockquote cite>` Support Rich Snippets

    Marking quoted material with `<blockquote>`/`<q>` and attributing the source with `<cite>` gives search engines structured signals that can surface as attributed quotes in rich results, whereas an unmarked `<div>` of quoted text is just anonymous body copy.

Best Practices

Choose Tags by Meaning, Not Appearance

Never reach for `<b>`/`<i>`/`<u>` just to get bold, italic, or underlined text — that's CSS's job (`font-weight`, `font-style`). Reserve `<strong>` for genuine importance, `<em>` for genuine stress emphasis, and use CSS for anything purely decorative.

Use `<del>`/`<ins>` for Real Document History, Not Strikethrough Styling

`<del>` and `<ins>` communicate an actual edit to the document (e.g. a price change), and some screen readers announce them as 'deletion'/'insertion'. Don't use `<del>` just to get a strikethrough look on unrelated text — use `text-decoration: line-through` for that.

<p><del>$40</del> <ins>$25</ins> — sale price</p>

Frequent Bugs

THE BUG

A price update styled with `<del>`/`<ins>` reads confusingly to screen reader users.

THE FIX

Add context so the deletion/insertion pairing is unambiguous when announced out of visual order, e.g. wrap both in a container with an `aria-label` like 'Price reduced from $40 to $25', since `<del>` and `<ins>` alone don't guarantee adjacent, linear announcement.

THE BUG

Nested `<q>` tags don't render the expected quotation marks in some older browsers.

THE FIX

`<q>` relies on the browser/CSS `quotes` property to auto-generate the correct nested quote characters (curly vs straight, outer vs inner) — verify with a CSS reset or explicit `quotes: '"' '"' "'" "'"` rule rather than assuming default styling is consistent.

Real-World Examples

Attributed Pull Quote in an Article

A blog post highlights a notable quote from a source using `<blockquote>` for the quoted passage, `<cite>` for the attributed work/author, and `<mark>` to highlight the single phrase a reader searched for when landing on the page.

<blockquote cite="https://example.com/interview">
  <p>The best code is the code you <mark>never had to write</mark>.</p>
</blockquote>
<cite>— Jane Doe, Lead Engineer Interview</cite>

Interview Prep

?Frequently Asked Questions

Pascual Vila

Pascual Vila

Frontend Instructor // Code Syllabus

Common Pitfalls & Errors

The Error //

Inputs missing associated <label> tags

<!-- Wrong --> <input type="text" name="username"> <!-- Correct --> <label for="username">Username</label> <input type="text" id="username" name="username">

The Solution //

For accessibility and usability, every form input must have a corresponding <label> linked via the 'for' and 'id' attributes.

The Error //

Forgetting the 'name' attribute on inputs

<!-- Wrong --> <input type="text" id="email"> <!-- Correct --> <input type="text" id="email" name="email">

The Solution //

Without a 'name' attribute, the input's data will not be submitted with the form to the server.

Lesson Glossary

[01]strong

An element used to indicate that its contents have strong importance, seriousness, or urgency.

Code Preview
<strong>

[02]em

Emphasis; an element used to indicate stress emphasis on its contents.

Code Preview
<em>

[03]code

An element used to represent a fragment of computer code.

Code Preview
<code>

[04]mark

An element used to represent highlighted text for reference purposes.

Code Preview
<mark>

[05]b (Bold)

A legacy element that specifies bold text without any extra semantic importance.

Code Preview
<b>

[06]i (Italic)

A legacy element that specifies italic text without any extra semantic importance.

Code Preview
<i>

[07]Monospace

A font where each character takes up the same amount of horizontal space, used for code.

Code Preview
UI

Continue Learning