TetSharing
HTML tutorial · 12 chapters
  1. Get started
  2. Elements and attributes
  3. Headings and paragraphs
  4. Text formatting
  5. Links
  6. Images
  7. Lists
  8. Tables
  9. Forms
  10. Input types and controls
  11. Semantic layout
  12. Head and metadata

Final HTML quiz

Chapter 4 of 12 · By Ethan Cole · Updated November 21, 2026

HTML Text Formatting: strong, em, code, mark and More

Inside a paragraph, some words deserve special treatment: a warning, a stressed word, a keyboard shortcut, a chemical formula. HTML has text-level elements for these. Pick them for what the text means; the default look (bold, italic, monospace) is just the browser's styling and can be changed with CSS.

Importance and emphasis

  • <strong> marks content of strong importance, seriousness or urgency, such as a warning label.
  • <em> marks stress emphasis, the word you would say differently out loud. "The oven is very hot" changes meaning when the stress moves.
  • <b> and <i> still exist for text that is styled differently without extra importance, such as a product name in a review (<b>) or a term from another language (<i>).

Screen readers and other tools can use these distinctions, so do not pick an element because of how it looks.

Code and technical text

<code> marks a fragment of computer code, <kbd> marks keys or input the user types, and <samp> marks output from a program. For multi-line code, wrap <code> inside <pre> so spacing is preserved.

HTML · editable

Expected page text

Warning: the oven is very hot.
Press Ctrl + C to copy. Call print() to show output.
Water is H2O and 210 is 1024.
Highlighted text and fine print.
Price: $20 $15
<p> is written with character references & shows as text.
A short quotation from a source.

Other inline elements

  • <sub> and <sup> give subscripts and superscripts, as in H2O and 210. Notice that the page text in the expected output reads "H2O" and "210": the meaning lives only in the markup, which is one reason to add context for maths.
  • <mark> highlights text for reference, like a search hit.
  • <small> is for side comments and fine print.
  • <del> and <ins> show removed and inserted text, for example a price change.

Quotations

<blockquote> holds a longer quotation as its own block, with an optional cite attribute giving the source URL. For a short quote inside a sentence, use <q>, which adds quotation marks automatically.

Character references

Some characters have special meaning in HTML. To display < literally, write &lt;; > is &gt; and & is &amp;. Others, like &nbsp; (a space that never breaks a line) and &copy;, are conveniences. With <meta charset="utf-8"> you can type most other characters, like é or €, directly.

Common mistakes

  • Using <b> and <i> everywhere when you mean importance or stress.
  • Typing a raw < in text, which the browser may read as the start of a tag.
  • Using <blockquote> just to indent text.

Summary

  • <strong> = importance, <em> = stress; <b>/<i> are purely stylistic offsets.
  • <code>, <kbd> and <samp> mark technical text.
  • <sub>, <sup>, <mark>, <small>, <del> and <ins> cover common inline needs.
  • Escape <, > and & as &lt;, &gt; and &amp;.

Quiz: Text formatting

1. Which element marks a word that would be stressed when spoken?

<em> is stress emphasis; <strong> is importance.

2. How do you display a literal < character in HTML text?

The character reference &lt; renders as <.

3. Which element is meant for keys the user presses?

<kbd> represents user input such as keyboard keys.

Official docs

Written under the pen name Ethan Cole with AI-assisted drafting. Every code example on this page is executed by our test suite before publishing. Found a mistake? Tell us.