Sub topic 7
Marking up meaning inside text
This chapter assumes you know basic HTML syntax (tags, attributes, nesting) and can open your browser's developer tools. It also assumes you have met the page-level elements from earlier chapters. Here we work inside a single paragraph. Text-level elements, which the HTML specification calls phrasing content, mark up individual words and phrases so they say what they are.
Meaning first, appearance second
Most text-level elements have a default style. strong is bold, em is italic, code is monospace. It's tempting to pick the element by the style you want. That produces markup that is wrong when the design changes, and wrong for people who never see the style.
The rule for this chapter is to ask what the text is, not how it should look. If you want bold text with no extra meaning, use CSS. If the text carries meaning, use the element for that meaning, and then style it however you like.
| Element | Meaning | Default style |
|---|---|---|
| `strong` | Strong importance, seriousness or urgency | Bold |
| `em` | Stress emphasis that changes the sense of a sentence | Italic |
| `mark` | Text highlighted for relevance in the current context | Yellow background |
| `code` | A fragment of computer code | Monospace |
| `kbd` | User input, such as a keystroke | Monospace |
| `abbr` | An abbreviation or acronym | Dotted underline in many browsers |
| `dfn` | The defining instance of a term | Italic |
| `q` | A short inline quotation | Quotation marks added |
| `cite` | The title of a creative work | Italic |
strong and em
strong marks importance. A warning, a required step or a key condition fits. It can be nested, and each level increases the importance.
em marks stress emphasis, the kind you hear when you read a sentence aloud. Moving the stress changes the meaning, and the markup should follow:
<p>I didn't say <em>she</em> took the money.</p>
<p>I didn't say she <em>took</em> the money.</p>The two sentences have different meanings, and the em position is what tells them apart. Nesting em raises the degree of stress.
The elements are easy to confuse because they look similar on screen:
strongis about importance, andemis about stress.- Both can appear in the same sentence without conflict.
- Neither should be used just to make a heading or a label look bold. That is a job for a heading element or for CSS.
<p><strong>Warning:</strong> do <em>not</em> unplug the device while it updates.</p>b and i: the leftovers
HTML also keeps b and i. They do not mean importance or stress. They mark text that is set apart in a different voice or mood, with no added weight.
- Use
bfor a keyword in a summary or a product name in a review, text you want to draw the eye to without claiming it is important. - Use
ifor a technical term, a foreign phrase, a ship name or a thought.
Reach for them only when no other element fits. A common mistake is using i for icon fonts, as in <i class="icon-save"></i>. An empty i says nothing, and many accessibility tools will skip it or read it oddly. Use a span with an accessible name, or an inline SVG with a text alternative, instead.
mark, small, s, del and ins
mark highlights text because it is relevant to something the reader is doing right now. A search results page that highlights the query is the classic case. It does not mean "important in general". That is strong.
small is for side comments and fine print, such as copyright lines and legal notes. It does not mean "make this text smaller". Do not wrap whole paragraphs or long legal text in it.
For changes to content:
delmarks text removed from the document, andinsmarks text added to it. Both acceptciteanddatetimeattributes.smarks text that is no longer accurate or relevant but was not edited out, such as an old price in a sale.
<p>Price: <s>$40</s> <strong>$30</strong></p>
<p>The meeting is on <del datetime="2026-11-30">Tuesday</del> <ins datetime="2026-11-30">Thursday</ins>.</p>code, kbd, samp, var, pre
Four elements cover technical text, and each has a distinct job:
codefor a piece of code, such as a function name.kbdfor input the user types or presses.sampfor sample output from a program.varfor a variable in a mathematical or programming expression.
<p>Run <code>npm install</code>, then press <kbd>Ctrl</kbd> + <kbd>C</kbd> to stop the server.</p>
<p>The terminal prints <samp>Server listening on port 3000</samp>.</p>
<p>The area of a circle is π<var>r</var><sup>2</sup>.</p>code marks inline text only. Browsers collapse whitespace inside it, so a multi-line listing needs pre around it. Also remember that < and & inside code must be written as < and &, or the browser will parse them as markup.
<pre><code>if (a < b && b < c) {
console.log("ordered");
}</code></pre>abbr and dfn
abbr marks an abbreviation. Its optional title attribute holds the expansion.
<p>The <abbr title="World Wide Web Consortium">W3C</abbr> publishes the HTML specification.</p>The title tooltip shows only on mouse hover. Keyboard and touch users usually never see it, and screen readers handle it inconsistently. A better habit is to spell out the term in the text the first time it appears, then use abbr for later mentions. Skip abbr for abbreviations everyone knows, such as "etc.", where it adds noise.
dfn marks the one place where a term is defined. The nearest enclosing paragraph, list or section is taken as the definition. If the term is also an abbreviation, nest abbr inside dfn:
<p>A <dfn>landmark</dfn> is a region of a page that assistive technology can jump to directly.</p>
<p>The <dfn><abbr title="Accessible Rich Internet Applications">ARIA</abbr></dfn> specification adds roles and states to HTML.</p>q, cite and blockquote
q is for short quotations inside a sentence. The browser adds locale-appropriate quotation marks, so do not type your own. For long quotations that stand alone, use blockquote, covered in the grouping chapter.
cite names a creative work: a book, article, film or song title. It does not mark the name of a person. Putting a person's name in cite is a long-standing error, and current specifications say it is wrong.
<p>As the spec puts it, <q cite="https://html.spec.whatwg.org/">elements describe content</q>, as discussed in <cite>HTML Living Standard</cite>.</p>sub, sup, bdi and span
sub and sup are for subscripts and superscripts when they carry meaning, as in H<sub>2</sub>O or 10<sup>3</sup>. Do not use them just to shift a typographic detail. bdi isolates text that may run in a different direction, such as a user-supplied name, so it cannot disturb the surrounding line. When no element matches, span with a lang attribute (for a language change) or a class is the fallback, as the earlier chapter on generic containers described.
A quick decision flow
What assistive technology does with these elements
Do not expect text-level elements to be announced. Most screen readers do not say "strong" or "emphasis" by default. Some can be configured to change voice or pitch, and many users never turn that on. Treat the semantics as a baseline for tools such as reader modes, translation, search indexing and style sheets, and keep critical information in the words themselves. "Warning:" works better than relying on bold alone.
Checking your work
Open the Elements panel in devtools and read the tag names without looking at the page. If a b or i appears where strong, em or an icon would fit, change it. Turn off author styles, or temporarily remove your stylesheet, and see whether the meaning still shows. If it doesn't, you used style where markup was needed.
Exercise
A recipe page contains this line: <p><b>Important:</b> keep the oven at <i>180°C</i>. Use <i>baking soda</i>, not baking powder.</p> Rewrite it with the most fitting text-level elements, assuming "180°C" has no special stress and the last instruction has stress on "not".
Show answer
<p><strong>Important:</strong> keep the oven at 180°C. Use baking soda, <em>not</em> baking powder.</p>. The label "Important:" carries importance, so it becomes strong. The temperature needs no element, because i was used only for looks. The word "not" changes the sense of the sentence when stressed, so it takes em.
Exercise
A tutorial writes <p>Press <code>Ctrl+S</code> to save.</p>. Which element is a better fit for "Ctrl+S", and why?
Show answer
Use <kbd>Ctrl</kbd>+<kbd>S</kbd>, or a single kbd element. The text is input the user performs, not a fragment of source code, and kbd says so.