What is the tag to underline text in HTML 5?

Discussion about HTML and XHTML related issues.
parkerchuks
Rank 0 - Newcomer
Rank 0 - Newcomer
Posts: 1
Joined: Sat May 12, 2012 5:19 pm

What is the tag to underline text in HTML 5?

Postby parkerchuks » Sat May 12, 2012 5:22 pm

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
Site Admin
Posts: 2861
Joined: Sat Dec 11, 2004 10:23 am
Location: Near Dallas, TX
Contact:

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

Postby Albert Wiersch » Sun May 13, 2012 7:55 am

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:
http://www.htmlvalidator.com/help.php?m ... decoration

I hope this helps!
Image
Albert Wiersch

worrall
Rank 0 - Newcomer
Rank 0 - Newcomer
Posts: 6
Joined: Sat Aug 25, 2012 8:06 am

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

Postby worrall » Sat Aug 25, 2012 8:20 am

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;}.


Return to “HTML and XHTML”

Who is online

Users browsing this forum: No registered users and 1 guest