HTML Formatting

HTML has special tags to format text, for example to make it bold, italic or highlighted. Some tags only change the look, and some also give a meaning to the text.

TagMeaning
<strong>Important text (bold)
<b>Bold text, without extra importance
<em>Emphasised text (italic)
<i>Italic text, like a technical term or thought
<mark>Highlighted text
<small>Smaller text, like a note
<del>Deleted text (line through)
<ins>Inserted text (underline)
<sub>Subscript
<sup>Superscript
<code>Computer code
<abbr>Abbreviation, with the full form in title
<q>, <blockquote>Short and long quotations

Example

<p>This is <strong>important</strong> and this is <em>emphasised</em>.</p>
<p>Please <mark>read this</mark> carefully.</p>
<p>Price: <del>$100</del> <ins>$80</ins></p>
<p>Water is H<sub>2</sub>O and 5<sup>2</sup> is 25.</p>
<p>Use the <code>print()</code> function.</p>
<p><abbr title="HyperText Markup Language">HTML</abbr> is easy.</p>
Output in the browser

This is important and this is emphasised.

Please read this carefully.

Price: $100 $80

Water is H2O and 52 is 25.

Use the print() function.

HTML is easy.


Quotations

<p>He said: <q>HTML is the base of the web.</q></p>
<blockquote cite="https://example.com">
  A longer quotation goes in a blockquote element.
</blockquote>
Output in the browser

He said: HTML is the base of the web.

A longer quotation goes in a blockquote element.


strong vs b, and em vs i

Visually they look the same, but strong and em tell the browser and screen readers that the text is important or emphasised. So prefer strong and em for normal text.

Note: Tags like <font>, <big>, <strike> and <tt> are removed from HTML5. Use CSS.

Summary

  • Use strong and em for importance and emphasis.
  • Use mark, del, ins, sub, sup and code for special text.
  • Use q and blockquote for quotes.
  • Next: HTML Comments.

Congratulations! Chapter Finished. Learn more about the similar topics:
Exercises & Assignments
Program to see difference between paragraphs & normal text with line break
Write a program to create a webpage to print values 1 to 5
Write a program to create a webpage to print your city name in red color.
Write a program to print a paragraph with different font and color.
Write an HTML program to display all six heading levels
Write an HTML program for text formatting (bold, italic, subscript, superscript)
Interview Questions & Answers
How to add comments in HTML?
How to add the copyright symbol to a web page?
What is the difference between strong and b tag in HTML?
What are HTML entities?
What is the difference between inline, internal and external CSS?