Loading...

HTML essentialsContent

Inline text formatting (strong, em, mark, sub, sup)

4 min lesson

Next
  • Inline formatting tags add meaning to a few words inside a paragraph without starting a new line.
  • <strong> marks important text, <em> marks emphasized text, and <mark> highlights text.
  • <sub> shows subscript, like H2O, and <sup> shows superscript, like x2.
  • These tags describe meaning first; the browser's default look (bold, italic) is a side effect.
  • This builds on Text, headings & paragraphs: you now style the words inside a block.
  • The example has one paragraph using all five tags; you will see bold, italic, highlight, subscript and superscript.
  • Next, Quotes, code & preformatted text adds more inline and block tags for special content.
Keep in mind
  • Use strong for importance and em for emphasis; both carry meaning.
  • Use mark only for genuinely highlighted text, like a search hit.
  • Use sub and sup for chemical formulas and math, not for layout tricks.
  • If you only want bold or italic looks, use CSS instead.
index.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Inline formatting</title>
</head>
<body>
  <!-- One paragraph showing each inline tag -->
  <p>
    <strong>Read this first</strong>, then <em>think carefully</em> about the <mark>key idea</mark>.
    Water is H<sub>2</sub>O, and the area of a square is side<sup>2</sup>.
  </p>
</body>
</html>

What happens: A paragraph reading "Read this first, then think carefully about the key idea. Water is H2O, and the area of a square is side2." with "Read this first" in bold, "think carefully" in italics, "key idea" highlighted, the 2 in H2O as subscript and the 2 after "side" as superscript.

Breaking it down

strong

<strong>Read this first</strong>

Marks text as important. Screen readers may stress it, and browsers show it bold by default.

em

<em>think carefully</em>

Marks emphasis. The meaning of the sentence changes slightly if you read it without the emphasis.

mark

<mark>key idea</mark>

Highlights text for reference, like a marker on paper. Browsers show it with a yellow background.

sub

H<sub>2</sub>O

Makes a subscript, used in chemical formulas. The 2 drops below the line.

sup

side<sup>2</sup>

Makes a superscript, used for exponents and footnotes. The 2 rises above the line.

Inline formatting tags

TagMeaningDefault look
strongImportant textBold
emEmphasized textItalic
markHighlighted textYellow background
subSubscriptLowered, smaller
supSuperscriptRaised, smaller

A helpful analogy

Inline formatting is like using a highlighter, bold pen and sticky note on a single line of a letter. The line still reads as one line, but certain words stand out for a reason.

Nesting rules

  • 1.Inline tags go inside a block like <p>, never the other way around.
  • 2.You may nest inline tags, for example <strong><em>very important</em></strong>.

Common mistakes

Using <b> and <i> just to look bold or italic

Avoid

<b>Important</b>

Use instead

<strong>Important</strong>

b and i carry no meaning. strong and em tell tools and screen readers why the text stands out.

Using sup for a footnote number without linking it

Avoid

text<sup>1</sup> with no link

Use instead

text<sup><a href="#note1">1</a></sup>

A superscript number alone is not clickable. Wrapping it in a link lets readers jump to the note.

Quick tips

  • •Read the sentence aloud: if you would stress a word, em is probably right.
  • •Use mark sparingly; too much highlighting makes nothing stand out.
Previous
Next