- Home
- /
- Tutorials
- /
- HTML Tutorial
- /
- HTML Formatting
HTML Basics
HTML Formatting
Formatting tags change how a few words inside a sentence look: bold, italic, underlined, highlighted, smaller, crossed out, raised or lowered. The better ones also say why the text is different, which matters to screen readers and search engines.
The key pairs to know: <b> and <strong> both look bold, <i> and <em> both look italic, but <strong> and <em> carry meaning. A fuller comparison is in HTML Text Formatting.
Bold and Strong Text
<b>makes text bold just to draw attention, like a product name.<strong>marks text as important, like a warning.
Formatting Example
html
<p>This is <b>bold text</b>.</p>
<p>This is <strong>strong important text</strong>.</p>Italic and Emphasized Text
<i>sets text apart, like a foreign word or a technical term.<em>stresses a word, the way you would when speaking.
Formatting Example
html
<p>This is <i>italic text</i>.</p>
<p>This is <em>emphasized text</em>.</p>Underline and Mark
<u>underlines text for a specific reason, like marking a spelling error. Readers may think underlined text is a link, so use it rarely.<mark>highlights text that is relevant right now, like a search match.
Formatting Example
html
<p>This is <u>underlined text</u>.</p>
<p>This is <mark>highlighted text</mark>.</p>Subscript and Superscript
Formatting Example
html
<p>H<sub>2</sub>O is water.</p>
<p>E = mc<sup>2</sup> is Einstein's formula.</p>Small and Deleted Text
<small>is for small print, like copyright lines.<del>marks text that was removed, shown crossed out.
Formatting Example
html
<p>This is <small>small text</small>.</p>
<p>This is <del>deleted text</del>.</p>Combining Formatting Tags
Tags can be nested. Close them in the reverse order you opened them: <strong><em>...</em></strong>.
Formatting Example
html
<p>This is <strong><em>bold and emphasized</em></strong> text.</p>Good to know
- Choose the tag for the meaning, not the look. For pure looks, use CSS such as
font-weightandfont-style. - Do not format whole paragraphs. Formatting stands out only when it is used on a few words.
Browser Support
Chrome | Edge | Firefox | Safari | Opera | IE9+ |
|---|---|---|---|---|---|
| Yes | Yes | Yes | Yes | Yes | Yes |
HTML Formatting exercises
An important warning
Write the paragraph Save first. This cannot be undone. with the second sentence (with its full stop) marked as important.
Result
