Hello there! In this lesson, we'll be exploring the wonderful world of text formatting in HTML. Text formatting allows you to emphasize, highlight, and style your text in various ways, making your content more engaging and visually appealing. Let's dive right in and learn about the different text formatting options available in HTML.
HTML provides several tags that you can use to format text within your paragraphs, headings, or other elements. Here are some of the most commonly used text formatting tags:
<strong>
tag makes the enclosed text bold. It is typically used to indicate strong emphasis or importance. For example, <strong>This text is
bold.</strong>
.<em>
tag italicizes the enclosed text. It is used to indicate emphasis or stress. For instance, <em>This text is italicized.</em>.
<u>
tag underlines the enclosed text. It can be used to highlight or emphasize certain text. For example,<u>This text is underlined.</u>
.<mark>
: The <mark>
tag adds a yellow background color to the enclosed text, creating a highlight effect. It is often used to mark important or relevant text. For instance,<mark>This text is highlighted.</mark>
.<del>
: The <del>
tag strikes through the enclosed text, indicating that it should be deleted or is no longer relevant. For example,<del>This text is deleted.</del>
.<ins>
: The <ins>
tag underlines the enclosed text and indicates that it has been inserted or added. It is often used to show updates or corrections. For instance, <ins>This text has been inserted.</ins>
.
<p>
This is a paragraph with <strong>bold</strong>,
<em>italic</em>, <u>underlined</u>,
<mark>highlighted</mark>, <del>deleted</del>,
and <ins>inserted</ins> text.
</p>
<sup>
and <sub>
TagsThe <sup>
and <sub>
tags are used for superscript and subscript text, respectively. Superscript text appears slightly above the baseline, while subscript text appears slightly below it. These tags are commonly used for footnotes, mathematical expressions, or scientific notations. Here's an example:
The temperature is 30<sup>o</sup>C.
The formula is H<sub>2</sub>O.
In the above code, "30o" will be displayed as superscript, and "2" will be displayed as subscript.
<abbr>
TagThe <abbr>
tag is used to create abbreviations or acronyms. It
provides a way to define the full form or meaning of the abbreviation.
When users hover over the abbreviated text, they can see the full form
in a tooltip. Here's an example:
The <abbr title="World Wide Web">WWW</abbr> is a global information system.
In this example, hovering over "WWW" will display "World Wide Web" as a tooltip.
Now it's time to put your knowledge into practice! Open your code editor and create a new HTML file. Experiment with the different text formatting tags and try creating content with various formatting options. Here's a simple exercise to get you started:
<p>This is an <strong>important</strong>
announcement!</p>
<sup>
and <sub>
tags for superscript and subscript text. For instance, <p>The formula is
E=mc<sup>2</sup>.</p>
In this lesson, we've explored the various text formatting options available in HTML. Text formatting allows you to emphasize, highlight, and style your text in different ways. Remember to use text formatting wisely, follow best practices, and always consider the readability of your content. In the next lesson, we'll move on to lists and learn how to present information in a structured and organized manner. Stay tuned, and happy coding!