In this post, we’ll learn how to format text in HTML, and we’ll explain it in detail. Before we begin, welcome to our website. Welcome!
Note: Before starting the explanation, I would like to tell you that you can do without these elements that I will explain, by using the CSS styling language.
The Bold element:
The <b> tag is primarily used to draw the reader’s attention to the element’s content. Formerly known as the bold element, it displays the element’s text in bold in the browser.
<b>Element content</b>
The Strong element :
The <strong> tag is used in content of great importance or urgency, and the text of the element is displayed in bold on the browser.
<strong>Element content</strong>
The Italic element:
The <i> tag is used as separate text on top of regular text, such as idiomatic texts or classificatory labels, and the element’s text is displayed in italics on the browser.
<i>Element content</i>
The Emphasis element:
The <em> tag is used in text that needs emphasis from the reader, in other words, it needs to be stressed, and the element’s text is displayed to the browser in italics.
<em>Element content</em>
The Underline element:
The <u> tag is used in non-textual content that requires visual checking by the reader, such as spelling mistakes, foreign terms, and unfamiliar phrases. When displayed on the browser, a line is displayed under the text containing the element.
<u>Element content</u>
The Strikethrough element:
The <s> tag is used for text that is no longer relevant or inaccurate in the document, and when viewed in a browser, a center line is added to the text inside the element.
<s>Element content</s>
The Inserted Text element:
The <ins> tag is used as a range of text added to the document. When viewed in a browser, a line is added under the text in the element.
<ins>Element content</ins>
The Deleted Text element:
The <del> tag is used as a range of deleted text from the document. When viewed in a browser, a center line is added to the text within the element.
<del>Element content</del>
The Small element:
The <small> tag is used in side comments and small texts such as copyright notices, and when viewed in a browser, the element’s content is displayed in small print.
<small>Element content</small>
The Mark element:
The <mark> tag is used for text that is highlighted, such as text that needs to be important, and when displayed on the browser, the text in the element is displayed with a yellow background.
<mark>Element content</mark>
The Sub element:
The <sub> tag is used in texts that need to appear as subtext in a small size, such as partial formatting. When displayed on the browser, the text in the element is displayed as subtext in a small size.
<sub>Element content</sub>
The Sup element:
The <sup> tag is used for texts that need to appear as top text, such as mathematical equations, and when viewed in the browser, the text in the element is displayed as top text in a small size.
<sup>Element content</sup>
How to use text formatting tags in an HTML page:
<DOCTYPE html!>
<html>
<head>
<meta charset="utf-8" />
<title>Page or Website Name</title>
</head>
<body>
<h1><em>What is Lorem Ipsum?</em></h1>
<p>
<strong>Lorem Ipsum</strong> is simply dummy text of the printing
and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since
the 1500s, when an unknown printer took a galley of type and scrambled it
to make a type specimen book. It has survived not only five centuries,
but also the leap into electronic typesetting, remaining essentially
unchanged. It was popularised in the 1960s with the release of Letraset
sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</body>
</html>
Note: When you insert an element inside another element in HTML, always make sure to close the inner element before the outer one. For more details, pay close attention to the HTML page listed above.
Here we have reached the end of this post, in which we learned How to format text in HTML.