HTML Text Formatting
Mark emphasis, importance, quotations, and code correctly.
HTML can mark importance, emphasis, quotations, code, keyboard input, edits, and scientific notation. These elements carry meaning that can survive visual redesign and be communicated by tools. Use CSS for purely decorative bold, italic, color, or size changes.
Mark meaning inside prose
Use strong for warnings or important decisions, em for verbal emphasis, mark for text relevant to the current context, small for side comments, and sub or sup for notation. Read the sentence aloud to decide whether emphasis changes its meaning.
<p><strong>Save your recovery codes.</strong> You may need them if you lose access to your device.</p>
<p>I said to test the <em>keyboard</em> flow, not only the pointer flow.</p>
<p>Search result: <mark>semantic HTML</mark></p>
<p>Water is H<sub>2</sub>O. The area is 5 m<sup>2</sup>.</p>- Use strong for importance.
- Use em for stress emphasis.
- Use mark for contextual relevance.
- Use small for side comments, not every small visual label.
- Use sub and sup for real notation.
Represent quotations, code, and edits
Use blockquote for a quoted section and q for a short inline quotation. cite identifies the title of a creative work, not the quoted person. code marks computer code, kbd marks user input, and del/ins identify edits.