The <u> Tag in HTML
Note: Contrary to the reports on other web sites and blogs, the <u> tag is not deprecated in HTML 5 and later. See Changes in HTML 5 below.
The <u> tag is used to visually highlight some content, without imparting any audible emphasis to it. Browsers will normally underline the text inside the u element, which draws the text with a solid underscore line.
In some languages the underline has a special meaning. In Chinese for example, a single straight underline is used to indicate a proper name, which can allow distinguishing one name from others marked in the same manner, and a wavy underline is similarly used to indicate the title of a book or other work of literature.
Here is a demo of HTML code for an entry in a bibliography:
- Rand, Ayn. Atlas Shrugged. New York: Random House, 1957; New York: Plume, 1999.
This is an actual working example of the <u> tag example code below.
In other contexts, use of the u element is discouraged for a number of reasons:
- underlined text that is not clickable can easily be confused with a hypertext link, especially in circumstances when their color cannot be used to distinguish between them
- for the separation of style and content, style information should be put into Cascading Style Sheets (CSS)
Therefore, the <u> tag should be avoided when possible. In most cases there are other HTML tags that would be more appropriate:
- the <b> tag can be used to highlight important words or phrases
- the <cite> tag can be used to display the title of a book or other creative work
- the <em> tag can be used to mark up text that is to be emphasized
- the <mark> tag can be used to mark words or phrases such as search terms
- the <strong> tag can be used to mark up text that is to be strongly emphasized
Text can also be underlined using the CSS text-decoration: underline
property.