Why do I get the following message in Visual Studio when I use the <u> element?
"Element 'u' is considered outdated. A newer construct is recommended"
Has it aged?
Why do I get the following message in Visual Studio when I use the <u> element?
"Element 'u' is considered outdated. A newer construct is recommended"
Has it aged?
It's because the W3C decided to deprecated it.
It's because all layout and design should be done using CSS. In HTML ideally only structure should exist.
<u>
only adds a specific font decoration to the text, but no structural information.
The tag is deprecated along with other text formatting / style elements.
The 'in' thing to do is to use correct markup and apply styling with stylesheets.
The underline tag has been deprecated as of HTML4.
http://www.w3.org/TR/html401/present/graphics.html#edef-U
The reason is that visual styling does not belong in tags, but should be moved to stylesheets.
You can use the text-decoration: underline style instead:
<span style="text-decoration: underline">some underlined text</span>
(Or use text-decoration:none to disable underlining.)
Formatting with HTML rather than CSS is considered deprecated these days. Anyhow, if you ever have issues with standards compliance rejecting your in-line formatting, follow the following easy search and replace rules:
<b></b> Replace with <span style=font-weight:bold></span>
<u></u> Replace with <span style=text-decoration:underline></span>
<i></i> Replace with <span style=text-font-style:italic></span>
<font face=font,otherfont size=number></font> Replace with <span style=font-family:font,otherfont;font-size:replace-with-keyword></span>
<s></s> aka <strike></strike> Replace with <span style=text-decoration:line-through></span>
Keywords for font-size: xx-small, x-small, small, medium, large, x-large, xx-large
Roughly the same.
If you will just follow through with these easy replacements, you will experience...!
Oh yeah...
Addendum: More seriously, because these days many standards purists just have a hard-on for pure CSS. Most of the support behind CSS obviating regular markup generates simply from it being modern so you should get with the times. Other support comes from the notion that CSS is inherently more maintainable and completely overlooks unmaintainable messes like what I suggested above.
It's not that I have anything against CSS. The point here is that a lot of people preach the standard excessively and will condone it even when it's used in wildly inappropriate ways. The notion of replacing regular HTML tags with inline formatted CSS as I mentioned is genuinely viewed as progress by far too many advocates of CSS. They seem to view upholding the standard, the pattern, the design rule, as being some kind of inherent good rather than rationally looking at it. Inline formatting has its place, and I think using regular HTML tags for it is fitting and much more readable.
Those adherents are like the folks who tell you gotos are evil and you should never, ever use them. The ones who will look at a regular stack-esque wind and unwind and instead use an indented if statement clusterfuck going ten layers of indentation and repeated code deep. And, they will genuinely view their version as more readable and maintainable even though by any sane standard it clearly isn't. For more on that tangent: http://kerneltrap.org/node/553/2131
As others have said, <u> (and similar elements) have been deprecated in the latest versions of web standards because of a general belief that style and markup should be separated.
And, as others have said, you can make your HTML valid by using a span with inline styling. Really though, that's not any better. Is it valid? Yes. But it buys you nothing else over simply using <u> tags in the first place.
The best semantic solution depends on the context. Why are you trying to insert an underline in text? There are three use cases I can think of: headings, links, and text emphasis. In each case you should be applying css from a stylesheet to the relevant semantic element: <h1-6> for headings, <a> for links, and <em> for emphasized text. If you need variations of each, apply css classes and ids as necessary.
<u> is part of a family of elements that were deprecated. <b> and <i> were replaced with <strong> and <em>, respectively, while requires using css for effect.
The reasoning is that HTML shouldn't decide that something is underlined or bolded, that type of information is supposed to be a part of the style, and thus is a perfect candidate for a stylesheet.
Not just HTML4, <u>
is considered obsolete in HTML5 too.
Interestingly, <b>
and <i>
are kept as conforming. You may try to argue in their mailing list, or just keep using the tag as you like before. Browsers won't pull out its support and you are fine.
I remember the reason behind the decision of pulling <u>
out is about its lack of uniform semantic meaning or something like that. At least when you see bold text you know you should read it louder.