Meaningful emphasis
Real content needs emphasis, and HTML gives it meaning, not just a look. That matters for the same reason headings did in lesson 2-2: screen readers change their voice for emphasized text and search engines weigh it, but only when you use the elements that carry meaning.
<p>Submissions close <strong>Friday at noon</strong>. You <em>must</em> include your email.</p>
strongmarks importance (deadlines, warnings). Browsers render it bold.emmarks stress emphasis, the word you would lean on when speaking. Browsers render it italic.
There are also b and i, which bold and italicize with no meaning attached. Prefer strong and em: same pixels, more information. If you only want the look with no emphasis intended, that is a CSS job (unit 4).
Comments and reserved characters
Two practical tools you will use in every real file.
Comments are notes for humans that the browser ignores. Teams use them to label regions and to temporarily disable markup while debugging:
<!-- TODO: swap placeholder logo before launch -->Character entities solve a real conflict: < and & are reserved — the browser reads < as the start of a tag. To display those characters as content, you write an entity, &name;:
| you want | you write |
|---|---|
| < | < |
| > | > |
| & | & |
So a page that displays the code <p> must be written as <p>, or the browser will try to interpret it as a real paragraph tag instead of showing it. Documentation sites do this constantly — this course's own code snippets rely on it.
Quiz
You want the text a < b to appear on the page. What do you write in the HTML?
Three fixes. 1) The deadline sentence should mark Friday at noon as important with <strong>. 2) The broken line is trying to display 5 < 10 — replace the < with the right entity so the text renders. 3) Add an HTML comment above the h1 that says: main title.
Problem
Which element marks text as important (not just bold-looking), so screen readers and search engines treat it as such?