Why use strong and em over b and i?
One question I see around the interwebs a lot is why strong
and em
should be used over b
and i
. If we look at the HTML 4 spec, it lists b
and i
under the Font style section, and notes:
The following HTML elements specify font information. Although they are not all deprecated, their use is discouraged in favor of style sheets.
The strong
and em
tags are listed under the Phrase elements section and note:
Phrase elements add structural information to text fragments.
Now that’s all well and good, but what does it mean?
Among other things:
b and i are visual.
What this means is that in a web browser, when the html parser encounters a <b>
tag, it knows to bold the font. It’s a physical property, meaning “use thicker ink when displaying this word.” Same with <i>
– “skew this so it looks like it’s going really fast” (or something like that). These are tags whose sole purpose is to physically change the display of the text.
Okay. Great.
Well, maybe not. What about when a blind person views a page? The visual properties mean nothing to them. That’s where em
and strong
come in.
em and strong are semantic
The em
tag indicates emphasis and the strong
tag indicates stronger emphasis. This could (and usually does) mean italics and bold on a web page. But it also could alert a text-to-speech program to use a different tone of voice when encountering the text. They have meaning behind them, and that meaning means different things to different interpreters.
As noted by the HTML 4 spec, b
and i
, although not deprecated, should be avoided because not only are they style properties that should be handled in CSS, they don’t have any semantic meaning. Use strong
and em
in their place.