advertisement
Formatting Text Using Tags in HTML
Formatting
The content format determines how the content will appear in the browser. For example, when you visit a Website, some text appears in a specific format such as bold or underlined. This means the formatted content makes an HTML page look readable and presentable. In HTML, formatting is applied to the text by using formatting elements, which are container elements.
Commonly used HTML formatting elements are as follows:
B
The B element displays text in bold. The text that must be displayed in bold is enclosed between <b> and</b> tags.
I
The I element displays text in italics. The text that must be displayed in italics is enclosed between <i> and </i> tags.
SMALL
The SMALL element makes text appear smaller in a browser. The smaller text must be enclosed between <small> and </ small> tags.
U
The U element applies an underline to the text. The text that must be underlined is enclosed between <u> and </u> tags.
You might want to display some text or characters above or below the baseline of its adjacent text. Further, you might want to apply strike through to some text to indicate that it is deleted. Therefore HTML provides you with some more formatting elements. These formatting elements are as follows:
DEL
The DEL element encloses text that has been deleted from the document. The text to be deleted is placed in the <del> and </del> tags.
INS
The INS element encloses text that has been inserted into the document. The text to be inserted is placed in the <ins> and </ins> tags. The INS element can be used with the DEL element to inform the user about the deleted text, which is replaced by new text.
STRONG
The STRONG element emphasizes text as compared to its surrounding text. The text to be emphasized is placed in <strong> and </strong> tags.
SUB
The SUB element displays the text as a subscript. The text to be displayed as a subscript is enclosed in <sub> and </sub> tags.
SUP
The SUP element displays text in superscript. The text to be displayed in superscript is enclosed in <sup> and </sup> tags.
Monospaced and preformatted text
By using monospaced fonts in HTML5, a Web developer can provide the same amount of horizontal space between fonts, even if font size, shape, and type are not the same. Monospaced fonts are used for programming code scripts, instruction texts, and ASCII characters.
The <pre> tag is used to apply preformatted text content to a Web page.
The <pre> tag applies a fixed font width to the text content. It also maintains standard formatting for spaces and line breaks. The <pre> tag is usually used when you want to copy-paste content from a source but do not want to change the formatting of the same. The content would be copied while maintaining all the line breaks and spaces.
Lists some of the other predefined tags available for the formatting of text in HTML.
- <em>: Used for emphasizing text
- <dfn>: Used for a definition term
- <code>: Used for a computer code
- <samp>: Used for sample output from a computer program
- <cite>: Used for a citation
1. Format a Block Quote
To define a long quotation or a block quotation, the <blockquote> tag can be used. When the <blockquote> tag is used, the quotation is indented in browsers.
advertisement
Conversation
Your input fuels progress! Share your tips or experiences on prioritizing mental wellness at work. Let's inspire change together!
Join the discussion and share your insights now!
Comments 0