8.HTML Formatting
8.HTML Formatting
HTML Formatting
HTML Formatting is a process of formatting text for better look and feel. HTML provides us
ability to format text without using CSS. There are many formatting tags in HTML. These
tags are used to make text bold, italicized, or underlined. There are almost 14 options
available that how text appears in HTML and XHTML.
Physical tag: These tags are used to provide the visual appearance to the text.
Logical tag: These tags are used to add some logical or semantic value to the text.
NOTE: There are some physical and logical tags which may give same visual
appearance, but they will be different in semantics.
Here, we are going to learn 14 HTML formatting tags. Following is the list of HTML
formatting text.
Element
name Description
<b> This is a physical tag, which is used to bold the text written between it.
<strong> This is a logical tag, which tells the browser that the text is important.
<tt> This tag is used to appear a text in teletype. (not supported in HTML5)
<big> This tag is used to increase the font size by one conventional unit.
<small> This tag is used to decrease the font size by one unit from base font size.
1/5
1) Bold Text
HTML<b> and <strong> formatting elements
The HTML <b> element is a physical tag which display text in bold font, without any logical
importance. If you write anything within <b>............</b> element, is shown in bold letters.
The HTML <strong> tag is a logical tag, which displays the content in bold font and informs
the browser about its logical importance. If you write anything between <strong>???????.
</strong>, is shown important text.
Example
1. <!DOCTYPE html>
2. <html>
3. <head>
4. <title>formatting elements</title>
5. </head>
6. <body>
7. <h1>Explanation of formatting element</h1>
8. <p><strong>This is an important content</strong>, and this is normal content</p>
9. </body>
10. </html>
2) Italic Text
HTML <i> and <em> formatting elements
The HTML <i> element is physical element, which display the enclosed content in italic font,
without any added importance. If you write anything within <i>............</i> element, is shown
in italic letters.
1. <p> <i>Write Your First Paragraph in italic text.</i></p>
Output:
The HTML <em> tag is a logical element, which will display the enclosed content in italic
font, with added semantics importance.
2/5
See this example:
1. <p><em>This is an important content</em>, which displayed in italic font.</p>
Output:
1. <!DOCTYPE html>
2. <html>
3. <head>
4. <title>formatting elements</title>
5. </head>
6. <body>
7. <h1>Explanation of italic formatting element</h1>
8. <p><em>This is an important content</em>, which displayed in italic font.</p>
9. </body>
10. </html>
Output:
4) Underlined Text
If you write anything within <u>.........</u> element, is shown in underlined text.
5) Strike Text
Anything written within <strike>.......................</strike> element is displayed with
strikethrough. It is a thin line which cross the statement.
1. <p> <strike>Write Your First Paragraph with strikethrough</strike>.</p>
Output:
3/5
Write Your First Paragraph with strikethrough.
6) Monospaced Font
If you want that each letter has the same width then you should write the content within
<tt>.............</tt> element.
Note: We know that most of the fonts are known as variable-width fonts because different
letters have different width. (for example: 'w' is wider than 'i'). Monospaced Font provides
similar space among every letter.
1. <p>Hello <tt>Write Your First Paragraph in monospaced font.</tt></p>
Output:
7) Superscript Text
If you put the content within <sup>..............</sup> element, is shown in superscript; means
it is displayed half a character's height above the other characters.
1. <p>Hello <sup>Write Your First Paragraph in superscript.</sup></p>
Output:
8) Subscript Text
If you put the content within <sub>..............</sub> element, is shown in subscript ; means it
is displayed half a character's height below the other characters.
1. <p>Hello <sub>Write Your First Paragraph in subscript.</sub></p>
Output:
9) Deleted Text
Anything that puts within <del>..........</del> is displayed as deleted text.
1. <p>Hello <del>Delete your first paragraph.</del></p>
Output:
Hello
4/5
10) Inserted Text
Anything that puts within <ins>..........</ins> is displayed as inserted text.
1. <p> <del>Delete your first paragraph.</del><ins>Write another paragraph.</ins></p>
Output:
1. <p>Hello <big>Write the paragraph in larger font.</big></p>
Output:
1. <p>Hello <small>Write the paragraph in smaller font.</small></p>
Output:
5/5