Text formatting tags help to highlight snippets of the written part of the page, either for SEO purposes or for content requirements.
Below are the common elements used for text formatting in HTML
b
andstrong
for bold/strong text;i
andem
for italics/emphasis;sup
andsub
for superscript and subscript, respectively;ins
anddel
to indicate snippets that have been added or removed, respectively;small
for text smaller than the default;mark
for highlighted text.
Although the <b
> and <strong
> tag have visually identical results, they have different uses.
The <b
> tag should be used when you want to highlight something that is just visual, such as making a link more visible.
The <strong
> tag, in addition to highlighting the visual, gives a semantic highlight to the text, so if the content you want to highlight is a relevant part of the text, use the <strong
> tag.
The same goes for the <i
> and <em
> tags, where the <i
> tag is used only for visual formatting and the <em
> tag gives semantic emphasis to the text,
Below is the example that demonstrates the use of these formatting tags.
<p>Text in bold with <b>bold</b> and <strong>strong</strong>.</p>
<p>Text in italics with <i>italics<i> and <em>emphasis</em>.</p>
<p>Text <sup>superscript</sup> and <sub>subscript</sub>.</p>
<p>Text <ins>inserted</ins> and <del>deleted</del>.</p>
<p>Text <small>small</small> and <mark>highlighted</mark>.</p>
Output: