While many HTML4 elements have been brought into HTML5 essentially unchanged, several historically presentational ones have been given semantic meanings.
Let’s look at
<b> and compare them to the semantic stalwarts
<strong>. In summary:
<i>— was italic, now for text in an “alternate voice”, such as foreign words, technical terms, and typographically italicized text (W3C:Markup, WHATWG)
<b>— was bold, now for “stylistically offset” text, such as keywords and typographically emboldened text (W3C:Markup, WHATWG)
<em>— was emphasis, now for stress emphasis, i.e., something you’d pronounce differently (W3C:Markup, WHATWG)
<strong>— was for stronger emphasis, now for strong importance, basically the same thing (stronger emphasis or importance is now indicated by nesting) (W3C:Markup, WHATWG)
Giving presentational elements new semantic meanings
<b> were HTML4 font style elements and are still used presentationally where appropriate to follow typographic conventions. They now have semantic meaning, however, and their style can be changed via CSS, meaning they’re not only presentational —
<b>, for example, doesn’t have to be bold. Because of this, it’s recommended to use classes to indicate meaning to make it easy to change the style later.
The i element represents a span of text in an alternate voice or mood, or otherwise offset from the normal prose in a manner indicating a different quality of text, such as a taxonomic designation, a technical term, an idiomatic phrase from another language, a thought, or a ship name in Western texts.
Other things that are typically italicised include foreign words (using the attribute
lang=""), inline stage directions in a script, some musical notation, and when representing hand-written text inline:
<i> when nothing more suitable is available — e.g.,
<em> for text with stress emphasis,
<strong> for text with semantic importance,
<cite> for titles in a citation or bibliography,
<dfn> for the defining instance of a word, and
<var> for mathematical variables. Use CSS instead for italicizing blocks of text, such as asides, verse, and (as used here for W3C specification quote) block quotations. Remember to use the
class attribute to identify why the element is being used, making it easy to restyle a particular use. You can target
lang in CSS using the attribute selector (eg
The b element represents a span of text to which attention is being drawn for utilitarian purposes without conveying any extra importance and with no implication of an alternate voice or mood, such as key words in a document abstract, product names in a review, actionable words in interactive text-driven software, or an article lede.
<b> text that should merely look different, there is no requirement to use
font-style: bold; — other styling could include a round-cornered background, larger font size, different color, or formatting such as small caps. For instance, in the script example above,
<b class="character"> is used to indicate who’s speaking or narrating.
Text that is bold by typographic convention (and not because it’s more important) could include names in a Hollywood gossip column or the initial text on a complex or traditionally designed page:
<b> when there are no other more suitable elements — e.g.,
<strong> for text with semantic importance,
<em> for emphasized text (text with “stress emphasis”),
<h6> for titles, and
<mark> for highlighted or marked text. Use classes on list items for a tag cloud. To recreate traditional typographic effects, use CSS pseudo-element selectors like
:first-letter where appropriate. Again, remember to use the
class attribute to identify why the element is being used, making it easy to restyle a particular use.
…and for comparison, the
<strong> have remained pretty much the same, there has been a slight realignment in their meanings. In HTML4 they meant ‘emphasis’ and ‘strong emphasis’. Now their meanings have been differentiated into
<em> representing stress emphasis (i.e., something you’d pronounce differently), and
<strong> representing importance.
The em element represents stress emphasis of its contents.
The ‘stress’ being referred to is linguistic. If spoken, this stress would be emphasised pronunciation on a word that can change the nuance of a sentence. For example, “Call a doctor now!” emphasises the importance of calling a doctor, perhaps in reply to someone asking “Should I get a nurse?” In contrast, “Call a doctor now!” emphasises the importance of calling immediately.
<strong> instead to indicate importance and
<i> when you want italics without implying emphasis. The level of nesting represents the level of emphasis.
The strong element represents strong importance for its contents.
Not much more to say really — it’s the
<strong> we all know so well. Indicate relative importance by nesting
<strong> elements, and use
<em> for text with stress emphasis, or
<b> for text that is “stylistically offset” or bold without being more important.
A final thing to note: these elements (and almost all HTML5 elements) have also been made explicitly media-independent, meaning their semantics are not tied to how they look in a visual browser.
So there you have it — two stray dogs of presentational HTML4 have been transformed into meaningful HTML5 elements, ready to be adopted into your coding once again. Can you resist their semantically shiny puppy-dog eyes? Let us know!
- I’ve updated mentions of using
<i>for foreign words to be specifically transliterated foreign words (what I was meaning), based on feedback in the comments. I’ve also updated spec quotes.