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.
o Physical tag: These tags are used to provide the visual appearance to the text.
o Logical tag: These tags are used to add some logical or semantic value to the text.
Here, we are going to learn 14 HTML formatting tags. Following is the list of HTML formatting text.
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.
The HTML <em> tag is a logical element, which will display the enclosed content in italic font, with added semantics
importance.
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>
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.
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.
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.
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.
9) Deleted Text
Anything that puts within <del>..........</del> is displayed as deleted text.
Hello
Output: