Home >Web Front-end >HTML Tutorial >HTML Text Formatting Tags
Formatting text is an important part of modern internet web pages; even when we were limited to having text-based web browsers, text formatting such as size, orientation, etc., was available. With modern HTML revisions, there are a ton of HTML Tags that can be used to make the text appearance to your liking.
Below we will discuss some important HTML tags that are used to format text:
HTML has two different tags to set the text to a bold appearance. One is and the other one is while both produce similar output. The tag is a physical tag, only to display the text in bold, and it does not add any value of importance in the browser.
Example
Code:
<!DOCTYPE> <html> <body> <p> <b>Here is some text in bold. </b></p> </body> </html>
Output :
The tag, on the other hand, is considered as a logical tag, and it is used to inform the browser that the text in the tag has some logical importance.
Example
Code:
<!DOCTYPE> <html> <body> <p> <strong>This is an important content formatted using the strong tag </strong>, and this is just normally formatted text</p> </body> </html>
Output:
Just as setting text as Bold, you can use tag and tag to set text as italic on HTML5.
Using is for, just like using , physical display of text as italic and the tag while also showing the text as italic on display, lets the browser know that it has semantic importance.
Example
Code:
<!DOCTYPE> <html> <body> <p> <i> This is the first para in italic text. </i></p> <p> <em> This content is made italics with the em tag</em>, This is normal text </p> </body> </html>
Output:
In situations where you want to highlight some text with a highlighter effect, the tag can be used; with default CSS, the tag makes the background of text as yellow, helping you grab a visitor’s attention on that text easily.
Example
Code:
<!DOCTYPE> <html> <body> <h3> This text uses <mark> Mark</mark> tag to highlight text on the page </h3> </body> </html>
Output:
The HTML tag can be used to add an underline in the text. Be careful not to use underlining with blue text as it may confuse visitors that the text is a link.
Example
Code:
<!DOCTYPE> <html> <body> <p> <u> This is Text with underline tag. </u> </p> </body> </html>
Output:
In cases where you need to draw a horizontal line through the text, tag can be used. The line drown is thin, so the text it is crossing can still be read easily.
Example
Code:
<!DOCTYPE> <html> <body> <p> <strike> Here is a sentence with strike through text </strike>. </p> </body> </html>
Output:
Using Monospace can be useful in situations where you want to quote something or you want to display some code in the browser. The Monospace code, as the name suggests, makes the width of every character the same. To get it on a browser, we have to use the tag.
Example
Code:
<!DOCTYPE>lt;html> <body> <p> This is normal text. <tt>This is some sample text in monospace fonts, neat. </tt> </p> </body> </html>
Output:
In math and chemistry, using subscript is an absolute requirement on many occasions. In general writing, too, you may come across situations where a subscript text is suitable to use. In HTML, any text under the tag will work as a subscript in the browser.
Example
Code:
<!DOCTYPE> <html> <body> <p> This is normal text <sub>Notice something different with this text? </sub> </p> </body> </html>
Output:
tag is used as a logical way of telling the browser that text inside the text is deleted. Keep in mind that to a user, the shown text is the same as the tag in strikethrough tag, meaning it is shown in strikethrough formatting.
Example
Code:
<!DOCTYPE> <html> <body> <p> This is normal text <del> This is text between del tag. </del> </p> </body> </html>
Output:
Text in tag is shown in superscript. This is useful in math, chemistry and other places where math is involved. You can use the tag when citing with adding in-page links with too.
Example
Code:
<!DOCTYPE> <html> <body> <p> This is Normal text<sup> This text is in superscript. </sup> </p> </body> </html>
Output:
In cases where you need some text in a larger size on the screen, but you don’t want to use a heading or increase the font size with a tag, use content between this tag will be displayed in noticeably larger text size.
Example
Code:
<!DOCTYPE> <html> <body> <p> This is Normal text <big> This text in in larger size. </big> </p> </body> </html>
Output:
Like the tag , you can use to make text smaller on the screen without using CSS or headings.
Example
Code:
<!DOCTYPE> <html> <body> <p> This is Normal text <small> the size of this text is smaller </small> </p> </body> </html>
Output:
Now that you have learned how the formatting of text in HTML works, you should be able to design pages with correct and professional-looking text layout and formatting. It would help if you used normal text and formatting where possible; using custom formatting only when needed gives your pages a neat look. The normal text size is important too, too small, and the readably will be affected negatively, and if it is too large, there will be less information on the screen at once.
The above is the detailed content of HTML Text Formatting Tags. For more information, please follow other related articles on the PHP Chinese website!