W3Schools HTML Underline Text: Complete Guide to Underline Text in HTML

Do you want to add emphasis to a specific text on your webpage without using a or tag? Underlining text in HTML is a simple way to achieve this. W3Schools offers an easy-to-understand guide on how to accomplish this.

How to add both an underline and an overline to your text (and in different colors) with HTML + CSS
How to add both an underline and an overline to your text (and in different colors) with HTML + CSS

The HTML tag is used to underline text. Let's dive into the details and explore some examples provided by W3Schools.

a red and black text description for a web page with an arrow pointing to it
a red and black text description for a web page with an arrow pointing to it

Experimenting with the Basic Tag

The tag is an inline element, much like or . It does not create a new line but underlines the text within its opening and closing tags. Here's a simple example provided by W3Schools:

Html notes
Html notes

Underline text here

Using the Tag with Text

About HTML tags
About HTML tags

You can use the tag with any type of text, not just a word or two. Here's an example where we underline a whole sentence:

This is an important sentence that we want to emphasize.

Styling Underlined Text

a poster with some text on it and an image of a computer coder in the background
a poster with some text on it and an image of a computer coder in the background

The underlined text created by the tag is typically rendered in a thin, solid line. However, you can style it using CSS. Here's how you can change the color, thickness, and style of the underline:

This text is underlined with a red, wavy line.

HTML5 and the Tag

how to create css custom text underline
how to create css custom text underline

In HTML5, the tag was initially deprecated due to the introduction of other elements like for emphasizing text. However, it has been reinstated in HTML5.1 for backward compatibility.

This reinstatement means that you can continue to use the tag in your HTML5 documents. It is fully supported in all modern browsers.

Perfect Html Note for New learners
Perfect Html Note for New learners
a computer screen with the text html and an image of a web page on it
a computer screen with the text html and an image of a web page on it
a table that has some type of text in red and black on the bottom right hand corner
a table that has some type of text in red and black on the bottom right hand corner
an image of a website page with the text'htmls'in white and green
an image of a website page with the text'htmls'in white and green
CSS Notes for Beginners (Easy + Quick Guide) 🎨
CSS Notes for Beginners (Easy + Quick Guide) 🎨
a web page with the words html and css in green, white and black
a web page with the words html and css in green, white and black
an image of a computer screen with text
an image of a computer screen with text
click on it to go to the website!!
click on it to go to the website!!
The HTML Backbone
The HTML Backbone
a blackboard with text and diagrams on it
a blackboard with text and diagrams on it
Coding a Stylish Blog Design Layout in HTML & CSS
Coding a Stylish Blog Design Layout in HTML & CSS
an image of a web page with the text'htmlformmating '
an image of a web page with the text'htmlformmating '
Autoplay Image Slider Tutorial | Build with HTML CSS & JavaScript
Autoplay Image Slider Tutorial | Build with HTML CSS & JavaScript
an image of a web page with the words'body'and'reader '
an image of a web page with the words'body'and'reader '
an image with the text how to place text over image in html css
an image with the text how to place text over image in html css
Complete Beginner CSS Master Notes
Complete Beginner CSS Master Notes
HTML Input Types – Complete Guide for Beginners
HTML Input Types – Complete Guide for Beginners
Glowing Text In HTML CSS
Glowing Text In HTML CSS
an image of a computer screen with the text css 4 2 written below it
an image of a computer screen with the text css 4 2 written below it
How To Create Text Slider With Pure HTML CSS
How To Create Text Slider With Pure HTML CSS

Accessibility Considerations

While underlining is a good way to emphasize text, it's important to note that not all users will see the underline. For instance, users with visual impairments might use screen readers that only read the text, not any additional styling. Therefore, it's good to use underlining alongside other methods of emphasis, such as changing the text color or using alternative text for images.

Best Practices

Use underlining sparingly. While it can draw attention to text, excessive use can make your webpage look cluttered and unprofessional. It's best to use it for important text like error messages, emphasize important points, or to create hyperlinks.

W3Schools provides an interactive demo for each example, allowing you to try different variations and see the results in real-time. So, why not head over to their HTML text underline tutorial and experiment with the tag yourself?