HTML Program to implement different HTML Tags for Text Formatting.


April 15, 2022, Learn eTutorial
1380

There are lots of tags available to format the text of an HTML page. Following is the list of tags you can use for text formatting.
1.    <b>…</b> 
The <b> tag is used to define a portion of the text in bold without carrying any special importance.

Syntax:
<b> This is bold text.</b>
 
2.    <strong> …</strong>
It is used to describe an important text which means, <strong.> tags should be used when the text has strong importance or a sense of urgency or seriousness. The <b> tag has not conveyed any tone of urgency or seriousness for the text; it brings only attention to a span of text without increased importance.

Syntax:
<strong> This is strongly important text </strong>

3.    <i>…</i>
The <i> tag is used to define a portion of the text in italic format. <i> tag is often used to represent a technical term, a thought, a phrase from another language, and taxonomical designations, etc.

     Syntax:
<i> This is italic text. </i>

4.    <em>…</em>
The <em>tag is used to define emphasized text. By default, the visual result of <em> and <i> tag is the same. However, the semantic meaning is different. The <em> element provides stress emphasis of its contents, while the <i> element represents text that is set off from the normal prose.

Syntax:
<em> This is emphasized text. </em>

5.    <mark>…</mark>
The <mark> tag is used to represent text that should be marked or highlighted.
Syntax:
<mark>This is highlighted text </mark>

6.    <code>…</code>
The <code> tag is utilized to define a piece of computer code. The content inside is exhibited in the browser's default monospace font. 

Syntax:
<code> This is computer code </code>

7.    <small>…</small>
The <small> tag is used to define smaller text (like copyright and other side-comments).

Syntax:
<small> This is small text</small>

8.    <sub>…</sub>
HTML subscript text can be defined with <sub> tag, which normally appears half a character below the normal line, and is sometimes rendered in a smaller font. For example, when dealing with the chemical formula of Water H2O, the number 2 is rendered as a subscript.
Syntax:
This is an example of <sub> subscript </sub>

9.    <sup>…</sup>
HTML superscript text can be defined with <sup> tag. For example, when dealing with an equation of mass-energy equivalence such as E=mc2, the number 2 is rendered as superscript. This superscript text has a smaller font and appears with a raised baseline. 

Syntax:
This is an example of <sup> superscript </sup>

10.    <del>…</del>
The <del> tag is used to represent a range of text that has been deleted or erased from a document. It will strike a line through deleted content.

Syntax:
 This is an example of <del>deleted text</del>.

11.    <ins>…</ins>
The <ins> tag can be used for the opposite purpose of <del> tag, which means, to indicate a range of text that has been added to the document. 

Syntax:
This is an example of <ins>inserted text</ins>

Let us see the example of an HTML program to implement different HTML Tags for Text Formatting.
 

HTML Source Code

                                          <!DOCTYPE html>
 <html>
<head>
        <title> HTML- TEXT FORMATTING  </title>
</head>
<body>
    <p>This is an example of <b>bold text</b>. </p>
    <p>This is an example of <strong>strongly important text</strong>. </p>
    <p>This is an example of <i>italic text</i>.</p>
    <p>This is an example of <em>emphasized text</em>.</p>
    <p>This is an example of <mark>highlighted text</mark>.</p>
    <p>This is an example of <code>computer code</code>.</p>
    <p>This is an example of <small>smaller text</small>.</p>
    <p>This is an example of <sub>subscript</sub> and <sup>superscript</sup> text.        </p>
  <p>This is an example of <del>deleted text</del>.</p>
    <p>This is an example of <ins>inserted text</ins>.</p><p>
 </body>
</html>   

                                      

OUTPUT

HTML