Text Formatting and Quotes
HTML has small tags that give words a special meaning. The browser also shows them differently, and screen readers read them out with the right stress.
Why not just make text bold with CSS? Because these tags carry meaning. <strong> says "this warning is important"; a screen reader changes its voice, and search engines notice it. The visual look is a side effect. When you mark up text by meaning, the page stays correct even if the design changes completely.
<del> and <ins> are a nice real-world example: online shops use them to show an old price crossed out next to a new price, and the meaning ("this was removed") is clear to every kind of visitor.
<strong>- very important text (shown bold)<em>- stressed text (shown italic)<mark>- highlighted text, like a marker pen<small>- side notes and fine print<del>and<ins>- removed and added text (great for old and new prices)<sub>and<sup>- H2O and x2
Example
<!DOCTYPE html>
<html>
<body>
<p><strong>Sale ends tonight!</strong> Do <em>not</em> miss it.</p>
<p>Price: <del>₹1,999</del> <ins>₹1,299</ins></p>
<p>Use code <mark>TERIXTO10</mark> at checkout.</p>
<p>Water is H<sub>2</sub>O and 5<sup>2</sup> = 25.</p>
<p><small>Prices include GST.</small></p>
</body>
</html>▶ Try it yourselfQuotes, code and abbreviations
<blockquote>- a long quote from somewhere else, shown indented<q>- a short quote inside a sentence (the browser adds the quote marks)<abbr title="...">- a short form; the full words show when you hover<code>- a piece of computer code, and<pre>keeps spaces and line breaks exactly as typed
Example
<!DOCTYPE html>
<html>
<body>
<blockquote>
Learning never exhausts the mind.
</blockquote>
<p>My teacher said <q>practise every day</q>.</p>
<p><abbr title="Goods and Services Tax">GST</abbr> is added to the bill.</p>
<p>Type <code>print("Hi")</code> to say hello in Python.</p>
<pre>
Name Price
Pen ₹20
Bag ₹900
</pre>
</body>
</html>▶ Try it yourselfUse
<strong> and <em> for meaning. If you only want a bold or italic look, use CSS (font-weight, font-style).Key points
- Formatting tags add meaning: strong, em, mark, small, del, ins.
- Quotes: blockquote for long, q for short; code and pre for computer code.
- Use CSS when you only want a look, not a meaning.
📝 Test yourself
1. Which tag marks text as very important?
2. Which pair is best for showing an old price and a new price?
3. Fill in the tag that keeps spaces and line breaks exactly as typed:
<> ... </pre>
