What is the tag to underline text in HTML 5?

For general web development questions that are not specifically related to CSS HTML Validator. This includes (but is not limited to) general HTML, CSS, Accessibility, JavaScript, and SEO questions.
Post Reply
parkerchuks
Rank 0 - Newcomer
Posts: 1
Joined: Sat May 12, 2012 5:19 pm

What is the tag to underline text in HTML 5?

Post by parkerchuks »

The tag that I am familiar with <u></u> to underline text is no longer valid in HTML 5, and has become outdated. How then, in the new HTML 5 language, do you underline text?
User avatar
Albert Wiersch
Site Admin
Posts: 3785
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: What is the tag to underline text in HTML 5?

Post by Albert Wiersch »

Hello,

The HTML5 specification says:
Use appropriate elements and/or CSS instead.

Where the tt element would have been used for marking up keyboard input, consider the kbd element; for variables, consider the var element; for computer code, consider the code element; and for computer output, consider the samp element.

Similarly, if the u element is being used to indicate emphasis, consider using the em element; if it is being used for marking up keywords, consider the b element; and if it is being used for highlighting text for reference purposes, consider the mark element.

See also the text-level semantics usage summary for more suggestions with examples.
Using CSS you can use:

Code: Select all

text-decoration: underline
Also see:
https://www.htmlvalidator.com/help.php? ... decoration

I hope this helps!
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
worrall
Rank 0 - Newcomer
Posts: 6
Joined: Sat Aug 25, 2012 8:06 am

Re: What is the tag to underline text in HTML 5?

Post by worrall »

According to me we can use the <u> tag for underlining text in html5 if this is not working you can go through css coding also, i just tried an example u go through this which is as follows...
<span style="text-decoration: underline;">text</span>.
This would be some extra code, you can store it in a css class {.underline text-decoration: underline;}.
Stella365
Rank 0 - Newcomer
Posts: 1
Joined: Sat Sep 01, 2018 10:56 am

Re: What is the tag to underline text in HTML 5?

Post by Stella365 »

The <u> tag works just fine in HTML5
Post Reply