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.
| Tag | Meaning |
|---|---|
<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
strongandemfor importance and emphasis. - Use
mark,del,ins,sub,supandcodefor special text. - Use
qandblockquotefor quotes. - Next: HTML Comments.
Congratulations! Chapter Finished. Learn more about the similar topics:
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |