HTML Formatting & Comments
Some text formatting tags are already provided in HTML.If it is not necessary, we can use these text formatting tags directly without having to write extra styles, which simplifies our work.
HTML Text Formatting Tags
Popular HTML text formatting tags are:
- <b> – Bold text
- <strong> – Important text
- <i> – Italic text
- <em> – Emphasized text
- <mark> – Marked text
- <small> – Small text
- <del> – Deleted text
- <ins> – Inserted text
- <sub> – Subscript text
- <sup> – Superscript text
The <b> element and the <strong> element
The <b> element defines a bold text:
<b>This is a bold text</b>
The <strong> element not only defines a bold text, but also indicates that this text is important:
<strong>This is a bold text, and it’s very important</strong>
The <i> element and the <em> element
Similar to the difference between the <b> element and the <strong> element, the <i> element defines an italicized text:
<i>This is an italicized text</i>
The <em> element not only defines an italicized text, but also indicates that this text is important:
<em>This is an italicized text and it's very important</em>
The <small> element
The <small> element defines a smaller text:
<h2>HTML <small>Small</small> Formatting</h2>
The <mark> element
The HTML <mark> element defines marked or highlighted text:
<h2>HTML <mark>Marked</mark> Formatting</h2>
The <del> element
The <del> element defines a deleted text:
<p>My favorite food is <del>noodles</del> rice.</p>
The <ins> element
The <ins> element defines an inserted text that is typically used with the <del> element to indicate deletion and updating of the content.
<p>My favorite food is <del>noodles</del> rice <ins>and fruit</ins>.</p>
The <sub> element and the <sup> element
The <sub> element defines a subscript text:
<p>The chemical formula of oxygen is O<sub>2</sub>.</p>
The <sup> element defines a superscript text:
<p>10<sup>2</sup> equals 100.</p>
HTML Comments
The comment tag allows you to add some comments in HTML documents.
HTML Comment Tag Syntax
The syntax of HTML comment tag is relatively complex. The following is the only way to write HTML comments:
<!-- This is the common html comment -->
Note:Notice that there is an exclamation point (!) in the opening tag, but not in the closing tag.
With comments you can place notifications and reminders in your HTML:
<!-- This is a comment -->
<p>This is a paragraph.</p>
<!-- Remember to add more information here -->
Comments are also great for debugging HTML, because you can comment out HTML lines of code, one at a time, to search for errors:
<!-- Do not display this at the moment
<a href="http://www.google.com" title="this is the google link">
-->