Is use of <u>underline</u> deprecated and non validated?

It's deprecated in HTML 4 http://www.w3.org/TR/REC-html40/present/graphics.html#edef-U so won't validate.

Use styles instead. Maybe a <span> tag. Although, if you want the thing you're trying to add an underline to, to be emphasized without styles enabled. Use an <em> tag and use CSS to give it an underline.


Yes, it's deprecated. Use styles instead. Note also that underlined text can be confusing, as it resembles the default styling of links, and might frustrate some users.

If you wanted, you could even repurpose another HTML element, like em:

CSS:

em {
  font-style: normal;         /* Removes italics */
  text-decoration: underline; /* Makes underline */
}

HTML:

<p>I like to <em>underline</em> words.</p>

<rant>

General comment on "semantics versus style": While there is certainly truth to this, it is a lesson that some people have way way overlearned.

In real life, many people use italics for emphasis. Sure, I could create a CSS style of "span.emphasized { font-style: italic;}", and then instead of putting "<i></i>" around the emphasized text, put "<span class='emphasized'></span>". And exactly what does that gain, besides a lot of extra typing?

Further, there are a million reasons why I might want to put a piece of text in, say, italics. Perhaps it is the title of a book; perhaps I want to emphasize it; perhaps I am using the convention of italicizing foreign words; etc. If I have 10 words in a document that are italicized for 9 different reasons, the pedantic answer is that I should create 9 different CSS style entries to describe all these reasons. Personally, I almost never do this, because it gains nothing. Yes, theoretically I might decide that book titles should be in a cursive font instead of italicized or some such. In practice, the probability that this will happen is pretty close to zero, and if it did, and I have two such book titles in my document, I can just change it twice. Theoretically someone might want to scan my text with a program that looks for book titles. But in practice, unless we have arranged this in advance and we have agreed on the CSS class names, there is no way they are going to do this.

I'm not saying CSS is useless. Quite the contrary. When I have a semantic object that is repeated many times in my text, and which has no "natural", widely-recognized style, it then becomes quite plausible to suppose that as I continue to work on the document I may want to change the style. In that case it is much easier to change a single CSS entry than to change a hundred instances. Or I may want to use a different style in different situations, like put warning messages in red when displaying on the screen but put them in bold when printing a black-and-white document.

For example, I routinely use CSS for quote citations because I often change my mind about italicizing, indenting, and font size. I never use CSS for text that I want italicized for emphasis because I know it is extremely unlikely that I will ever want to render this as anything other than italics.

My point is, I don't care that some pedant said "This is a rule that you must always obey. You ask why you must obey it? But I just told you! Because it's a rule!" I use tools and techniques that are useful in the present application. (And yes, yes, there are lots of rules of thumb that are valid 99% of the time and aren't worth thinking about until the rare exception turns up.)

</rant>

Tags:

Html

Xhtml

W3C