HTML Text Formatting

Learn how to properly format text in HTML with semantic meaning

<strong>, <b>

Bold text - <strong> for important text, <b> for stylistic bold

<p><strong>Important text</strong> and <b>bold text</b></p>

<strong> is semantic, <b> is presentational

<em>, <i>

Italic text - <em> for emphasized text, <i> for stylistic italic

<p><em>Emphasized text</em> and <i>italic text</i></p>

<em> is semantic, <i> is presentational

<u>

Underlined text (avoid for links to prevent confusion)

<p><u>Underlined text</u> example</p>

Presentational only

<mark>

Highlighted text for reference or notation purposes

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

Semantic - indicates relevance

<code>

Inline code snippet or computer code

<p>Use <code>console.log()</code> for debugging</p>

Semantic - indicates code

<sub>

Subscript text (lowered and smaller)

<p>Chemical formula: H<sub>2</sub>O</p>

Semantic - indicates subscript

<sup>

Superscript text (raised and smaller)

<p>Mathematical notation: x<sup>2</sup></p>

Semantic - indicates superscript

<del>, <ins>

Deleted and inserted text (for document edits)

<p><del>$100</del> <ins>$80</ins> (limited time)</p>

Semantic - indicates changes

<strong> vs <b>

<strong> indicates importance, <b> is just visual boldness

Impact: Screen readers emphasize <strong> content

<em> vs <i>

<em> adds verbal stress, <i> is just visual italic

Impact: Screen readers change tone for <em> content

<mark>

Indicates text that is relevant or should be highlighted

Impact: Helps users find relevant content

<del> & <ins>

Shows document edits with semantic meaning

Impact: Clearly shows document changes

Semantic vs Presentational

Use semantic elements when meaning is important

Recommended

Avoid

Why: Semantic elements convey meaning to assistive technologies

Avoid Overuse

Don&apos;t overuse formatting as it loses effectiveness

Recommended

Avoid

Why: Too much formatting makes content harder to read

CSS for Styling

Use CSS for purely visual formatting

Recommended

Avoid

Why: CSS provides more control and separates content from presentation

Accessibility

Ensure proper contrast and readable text

Recommended

Avoid

Why: Low contrast text is hard to read for many users

Academic Paper Formatting

Technical Documentation

E-commerce Product Page

Text Formatting Playground

Experiment with HTML text formatting in our live editor

Formatting Examples Preview

Ready-to-use examples covering different formatting scenarios

Live Preview

Formatting Elements

<strong>
Bold importance
<em>
Emphasized
<mark>
Highlighted
<code>
Code snippet

All examples will be loaded into an interactive editor where you can modify and test them

< PreviousNext >