Formatting Text with HTML: Bold, Italic, and Underline

Formatting text is an important aspect of web design and user experience. Whether you want to draw attention to a particular word or phrase, or just add some emphasis to your content, HTML provides several tags for formatting text. In this tutorial, we’ll cover the basics of bold, italic, and underline text using HTML.

Step 1: Bold text

The <strong> tag is used to bold text in HTML. The text inside the <strong> tags will be displayed in a heavier font weight and is usually used to highlight important or emphasized text.

Here’s an example of how to use the <strong> tag:

Copy to Clipboard

This will produce the following output:

This is a bold word.

Note that the <strong> tag is semantic, which means that it conveys meaning to search engines and assistive technologies. An alternative to the <strong> tag is the <b> tag, which is used to simply render text as bold without conveying any additional meaning.

Step 2: Italic text

The <em> tag is used to italicize text in HTML. The text inside the <em> tags will be displayed in an italicized font style and is usually used to denote emphasis or stress.

Here’s an example of how to use the <em> tag:

Copy to Clipboard

This will produce the following output:

This is an italicized word.

Like the tag, the tag is semantic and conveys meaning to search engines and assistive technologies. An alternative to the tag is the tag, which is used to simply render text as italicized without conveying any additional meaning.

Copy to Clipboard

This will produce the following output:

This is an underlined word.

The <ins> tag is a semantic alternative to the deprecated <u> tag, which was used to underline text in HTML. While the <u> tag is still supported by most web browsers, it is not recommended for use in new projects due to its lack of semantic meaning.

Another alternative to underlining text is the <mark> tag, which is used to highlight text and is typically displayed with a yellow background.

Conclusion

In this tutorial, we’ve covered the basics of bold, italic, and underlined text using HTML. Whether you want to add emphasis or highlight important words and phrases, these formatting tags are a simple and effective way to enhance the appearance and readability of your content.

Try using these tags in your own HTML projects and see the difference they can make. For more information on text formatting in HTML, check out these resources.

  • W3Schools HTML Formatting Reference: This comprehensive reference provides detailed information on various HTML tags and attributes used for formatting text, including <strong>, <em>, <ins>, <mark>, and more. It includes code examples and live demos, as well as information on browser support and related techniques.
  • MDN Web Docs: HTML Text Formatting: This resource from the Mozilla Developer Network provides in-depth information on text formatting in HTML, including semantic tags, deprecated tags, and alternative techniques. It also includes information on advanced topics such as text styling with CSS and internationalization.
  • Codecademy: HTML Text Formatting: This interactive tutorial from Codecademy provides a hands-on introduction to text formatting in HTML, including exercises and quizzes to test your understanding. It covers the basics of bold, italic, and underline text, as well as other formatting tags and techniques.

Here is an example of using the <mark> tag to highlight text in an HTML page:

Copy to Clipboard

This will produce the following output:

This is some text with a highlighted word.

The tag is used to highlight text and is typically displayed with a yellow background. It is a semantic tag that can be used to indicate the importance or relevance of certain words or phrases in the context of the page.

I hope these resources and examples are helpful for learning more about text formatting in HTML!

The <strong> tag is used to bold text and is typically displayed in a heavier font weight. It is a semantic tag that conveys meaning to search engines and assistive technologies, indicating that the text is important or emphasized.