Emmanuel Akinfulubi

HTML and CSSHTML and CSS

When to use em, strong, i and b in HTML

2 Emphasis that means something

easy

Mark 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. 1. <em> is stress emphasis; <strong> is importance. Both are announced.
  2. 2. <i> is for a different voice or mood: a taxonomic name, a foreign phrase, a ship. It carries no emphasis.
  3. 3. If you only want bold or italic pixels, that is a CSS job, not an element.

index.html

<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>

style.css

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;
}
Rendered result. Shown, not machine-checked: there is no browser in the build.
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.

Checks for exercise 2

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.

Newsletter

New writing, when it lands.

Occasional notes on shipping software with AI agents. No schedule, no filler, unsubscribe in one click.