More HTML answers

by Danny
Published 3 min read

strong and em carry meaning: importance and stress. b and i are for text that is styled differently without extra importance. Here is when to reach for each one.

The short answer

#

Use strong when the text is important, serious or urgent. Use em when you would stress the word if you said the sentence out loud. Use b and i when text should look different but is not more important, such as a keyword, a product name, a foreign phrase or a technical term. If you only want a visual style, use CSS.


_10
<p><strong>Warning:</strong> this deletes all your data.</p>
_10
<p>I <em>did</em> lock the door.</p>
_10
<p>The <i lang="fr">raison d'être</i> of the project is speed.</p>
_10
<p>Open the <b>Settings</b> panel and choose <b>Privacy</b>.</p>

Why it happens

#

In early HTML, b meant bold and i meant italic, purely as presentation. HTML 4 added strong and em as the "meaningful" versions, and for years the advice was simply "never use b or i". That advice is out of date.

The HTML standard now gives all four elements a meaning, and the default bold or italic style is just how browsers show them:

  • strong: strong importance, seriousness or urgency.
  • em: stress emphasis, which changes the meaning of the sentence.
  • b: text you want to draw attention to without making it more important, such as keywords in a summary, product names or the lead sentence of an article.
  • i: text in an alternate voice or mood, such as foreign words, technical terms, taxonomic names, a character's thoughts, or ship names.

The choice matters for anyone who gets the text without the visual styling, including search engines, reader modes, translation tools and some screen reader set-ups. It also makes intent clear to the next person who edits the content.

How to fix it

#

Ask whether the meaning changes

Read the sentence aloud. If moving the emphasis changes what you mean, use em.


_10
<p><em>I</em> did not take the biscuit.</p> <!-- someone else did -->
_10
<p>I did not take the <em>biscuit</em>.</p> <!-- I took something else -->

If the text is a warning, a key instruction or something the reader must not miss, use strong. You can nest strong to show increasing importance, though that is rarely needed.

Use b and i for conventions, not importance

When typographic convention says a phrase should look different, but it is not more important, use b or i. Add lang to foreign phrases so screen readers pronounce them correctly.


_10
<p>The <i>Homo sapiens</i> genome was first sequenced in 2003.</p>
_10
<p>We sailed on the <i>Queen Mary 2</i>.</p>
_10
<p><b>Summary:</b> sales grew in every region.</p>

There is often a more specific element. Use cite for the title of a work, dfn for the defining instance of a term, mark for highlighted or search-matched text, and kbd for keys the user presses.


_10
<p>Press <kbd>Ctrl</kbd> + <kbd>S</kbd> to save.</p>
_10
<p>I re-read <cite>The Pragmatic Programmer</cite> last month.</p>

Use CSS for purely visual styling

If a design calls for bold headings in a card, bold table totals or italic captions, that is styling. Use a class and font-weight or font-style instead of adding elements.


_10
.card-label {
_10
font-weight: 600;
_10
}
_10
_10
figcaption {
_10
font-style: italic;
_10
}

In rich text and Markdown

Markdown **text** and most rich text editors output strong, and *text* outputs em. That is usually what writers mean, so you rarely need to change it. If you build an editor, map the bold button to strong and the italic button to em.

Common pitfalls

#
  • Expecting screen readers to announce emphasis. Most screen readers do not change their voice for strong or em with default settings. Do not rely on emphasis alone to convey critical meaning; say it in words too.
  • Using strong for headings. A bold line that introduces a section should be a real heading element, so it appears in the document outline.
  • Using em or i for icons. The old icon-font habit of i class="icon" gives the wrong meaning. Use a span or an inline SVG with aria-hidden="true".
  • Emphasising everything. If half the paragraph is in strong, nothing stands out. Use it sparingly.
  • Assuming b and i are deprecated. They are valid, current HTML with their own defined meanings.
#

Was this resource helpful?