Text Formatting Tags in HTML5
Text formatting tags in HTML are used to control the appearance and layout of text content within a web page. Here are some commonly used text formatting tags:
<b>
: Renders text in bold.Example:
<b>This text is bold</b>
<strong>
: Indicates that text is of strong importance, typically rendered in bold.Example:
<strong>This text is important</strong>
<i>
: Renders text in italics.Example:
<i>This text is italicized</i>
<em>
: Indicates emphasis, typically rendered in italics.Example:
<em>This text is emphasized</em>
<u>
: Renders text with an underline.Example:
<u>This text is underlined</u>
<s>
or<strike>
: Renders text with a strikethrough.Example:
<s>This text has a strikethrough</s>
or<strike>This text also has a strikethrough</strike>
<sub>
: Renders text as subscript (below the normal line).Example:
H<sub>2</sub>O
<sup>
: Renders text as superscript (above the normal line).Example:
E=mc<sup>2</sup>
These tags can be used individually or in combination to achieve the desired text formatting. However, it's important to note that HTML5 encourages the use of semantic markup (e.g., <strong>
for importance, <em>
for emphasis) rather than purely presentational markup (e.g., <b>
for bold, <i>
for italics) whenever possible to improve accessibility and search engine optimization (SEO). Also learning from online HTML tutorial and a web development course can be helpful in the tech journey!