When to use em, strong, i and b in HTML
2 Emphasis that means something
easyMark up stressed words and important words with the elements that carry that meaning. Then use <i> for the one job it still has, and leave <b> alone.
Stuck? Three hints, smallest first
- 1.
<em>is stress emphasis;<strong>is importance. Both are announced. - 2.
<i>is for a different voice or mood: a taxonomic name, a foreign phrase, a ship. It carries no emphasis. - 3. If you only want bold or italic pixels, that is a CSS job, not an element.
<p>The last bus leaves at <strong>21:30</strong>, not 22:00.</p>
<p>Bring the ticket <em>and</em> the receipt; one alone is not enough.</p>
<p>The park is named after the <i lang="yo">jibowu</i> tree that stood at the gate.</p>
strong {
font-weight: 700; /* already the default; stated so it is deliberate */
color: #a3341f;
}
/* em stays italic. Restyling it to bold would make it look like strong while
still being announced as emphasis, so the two would disagree. */
em {
font-style: italic;
}
i[lang] {
font-style: italic;
color: #5c5c66;
}
7 checks that prove this answer
Assertions, run in the browser. The markup and styles above are handed to them
as html and css, so press Run and each check prints
ok. The build fails if a single one fails.
test('stress emphasis uses em', hasTag(html, 'em'), true);
test('importance uses strong', hasTag(html, 'strong'), true);
test('the different-voice case uses i', hasTag(html, 'i'), true);
test('and names its language, which is the point of it', /<i lang="yo">/.test(html), true);
test('b is not used to mean important', /<b\b/.test(html), false);
test('em is not restyled to look like strong', /em\s*\{[^}]*font-weight/.test(css), false);
test('strong is styled, and stays bold', /strong\s*\{[^}]*font-weight\s*:\s*700/.test(css), true);
Output
<em> and <strong> are announced — a screen reader can change pitch or stress for them — while <b> and <i> are not. That is the whole distinction, and it is why the sixth check refuses to give em a font-weight: a bold em looks like importance but is announced as emphasis, so the appearance and the meaning drift apart. <i> is not deprecated; it just means “another voice” now, which is why it pairs with lang here.