Select Page

Top 10 HTML5 formatting tags


HTML offers a range of elements for formatting text.


nanadwumor

June 02, 2023

HTML - formatting tags


HTML formatting tags include :

  • <b> – Bold text
  • <strong> – Important text
  • <i> – Italic text
  • <em> – Emphasized tex
  • <mark> – Marked tex
  • <small> – Smaller text
  • <del> – Deleted text
  • <ins> – Inserted text
  • <sub> – Subscript text
  •  <sup> – Superscript text

RECOMMENDED ARTICLES



(1) <b> – Bold text

The <b> tag is used to bolden text.

Syntax

<b>This is a bold text </b>

Let’s look at a program that uses the <b> tag to format text

Output

10 formatting tags - b tag

Join Other Subscribers on Our YouTube Channel and Don’t Miss a thing!


(2) <strong> – Important text

The <strong> tag is used to make text bold while placing emphasis on the text that it’s important.

Syntax

<strong> This is important text </strong>

When the <strong> element is used, it indicates that its contents have strong importance or seriousness. Browsers render the contents in <strong> tag in bold type.

Let’s look at a program that uses the <strong> tag to format text

Output

10 formatting tags - strong- tag

(3) <i> – Italicized text

The <i> tag is used to italicize a text or group of text without placing importance or emphasis on it.

Syntax

<i> This is italicized text </i>

The <i> tag is mostly used to indicate a technical term, a phrase, a thought, etc

The <i> element is typically used if there is not a more appropriate semantic element to use.

Output

10 formatting tags - i- tag

(4) <em> – Italicized text (Emphasized text)

The <em> tag is used to italicize text or group of text while placing emphasis or importance on the text. It defines an emphasized text.

For instance, a screen reader will pronounce the words in <em> with an emphasis with a verbal stress.

Syntax

<em> This is emphasized text </em>

Output

10 formatting tags - em- tag

(5) <mark> – Marked/Highlighted text

As the name suggests, the <mark> tag in HTML is used to define a marked text.

The <mark> tag highlights the text. By default, the <mark> tag highlights the text content in yellow color. This can be changed using CSS.

The <mark> tag is used to highlight the part of the text in a paragraph. It is one of the new tags introduced in HTML 5.

Syntax

<mark> This is marked text </mark>

Output

10 formatting tags - mark tag

(6) <small> – Smaller text

The <small> tag in HTML is used to set text to small font size.

The tag decreases the font size by one size. For instance, if the original font size is x-large, <small> tag will decrease it to just large. If it’s large it’ll decrease it to medium. If it’s medium, it’ll decrease it to small in that order.

As the name implies, the <small> tag makes text smaller. It is used to define smaller text like copyright and other side-comments.

Syntax

<small> This text is small </small>

Output

10 formatting tags - small- tag

Using CSS to achieve similar results

If the <small> tage is used to mark text, it decreases the font size by just a size.

For instance, if the text has large font, it degrades it to medium.

There are situations you would want to reduce the font size to any size you want. For instance, you can decrease the font size from xx-large to smaller.

This can be achieved using CSS.

Ways of using the <small> tag

Basically, there are two ways that the <small> tag can be employed.

(i) Using it in a nested form :

The <small> tag respects the size of its parent.

When you use the <small> tag in a nested form then the <small> tag will going to change the font size of the text in between it with respect to the parent element’s font size which means changing text with respect to its surroundings.

Program demonstrates the use of <small> in nested form

Output

10 formatting tags - small- tag-Nested

Because, the nested <small> tag is responsive to the font of its parent element, if we increase the font size of the parent element, the font size of the <small> tag will automatically increase its text too.

Program demonstrates increase in font size of <small> tag as result of change in font of parent element

Output

small nested tag.2

It is possible to use CSS to achieve smaller or even richer text instead of using the <small> tag.

(ii) <small> in a non-nested form:

The font of the content of the <small> tag is not affected if it isn’t within any other element if font of that element is changed.

Program demonstrates that font of the <small> tag remains unchanged with change in font size of a non-parent element

Output

small non-nested tag

(7) <del> – Deleted text

The <del> tag is used to mark a portion of text that has been deleted from the document.

<del> is short for delete.

The deleted text appears as a strike-through text in web browsers. The <del> tag requires a starting and ending tag.

Syntax

<del> …deleted text here… </del>

Program demonstrates the <del> tag

Output

10 formatting tags - del tag

Changing the default CSS of the <del> tag

Like any other HTML tag, the default appearance of a deleted text can be altered by using CSS. This is done by changing the value of the text-decoration property.

NOTE: <del> CSS property changed from strike through to underline.

Attributes of <del> tag

 The <del> tag contains two attributes. These are:

 (1) cite : The cite attribute is used to specify the URL of the document. It can also be used to hold a message that explains why the text was deleted.

Program demonstrates the cite attribute in the <del> tag

Output

del tag dcite tag

 (2) datetime : This attribute is used to specify the date and time that the text was deleted.

Output

del tag datetime

(8) <ins> – Inserted text

In HTML, the <ins> tag is used to specify a block of text that has been inserted into the HTML document.

That is, the <ins> tag is typically used to show a group of text that has been inserted or added to the HTML document.

The inserted text appears as underlined text in the web browsers. The <ins> tag has an opening and closing tag.

Syntax

<ins> …deleted text here… </ins>

Program demonstrates the <ins> tag

Output

ins tag

Changing the default CSS of the <ins> tag

The default property of the <ins> tag can be changed by changing the value of the text-decoration property.

Program demonstrates the change of text decoration of <ins>

NOTE: <ins> CSS property was changed from underline to overline.

(9) <sub> – Subscript text

The <sub> tag is used to render text a subscript in an HTML document.

The subscript text appears as half of a character below the normal line. This is at times displayed in smaller font.

Subscripts are used mostly in math and science and other disciplines. Example, the <sub> tag can be used to write formula water as H20.

Syntax

<sub> …deleted text here… </sub>

Program demonstrates the <sub> tag

Output

sub tag

Another Example:

Output

sub-example-2

(10) <sup> – Superscript text

The <sup> tag is used to add a superscript text in an HTML document.

Superscript text appears half of a character above the normal line. 

It is typically displayed in smaller font. A typical use of the <sub> tag is footnotes.

Syntax

<sup> …deleted text here… </sup>

Program demonstrates the <sup> tag

Output

sup tag

Another Example:

Output

sub-example-2

Join Our Telegram Group

Join Our WhatSapp Group



You May Also Like…




0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *