Do we need type="text/css" for <link> in HTML5

CssHtml

Css Problem Overview


> Possible Duplicate:
> Is type=“text/css” necessary in a <link> tag?

Do we need type="text/css" for <link> tag in HTML5?

Css Solutions


Solution 1 - Css

The HTML5 spec says that the type attribute is purely advisory and explains in detail how browsers should act if it's omitted (too much to quote here). It doesn't explicitly say that an omitted type attribute is either valid or invalid, but you can safely omit it knowing that browsers will still react as you expect.

Solution 2 - Css

Don’t need to specify a type value of “text/css”

Every time you link to a CSS file:

<link rel="stylesheet" type="text/css" href="file.css">

You can simply write:

<link rel="stylesheet" href="file.css">

Solution 3 - Css

For LINK elements the content-type is determined in the HTTP-response so the type attribute is superfluous. This is OK for all browsers.

Solution 4 - Css

You don't really need it today, because the current standard makes it optional -- and every useful browser currently assumes that a style sheet is CSS, even in versions of HTML that considered the attribute "required".

With HTML being a "living standard" now, though -- and thus subject to change -- you can only guarantee so much. And there's no new DTD that you can point to and say the page was written for that version of HTML, and no reliable way even to say "HTML as of such-and-such a date". For forward-compatibility reasons, in my opinion, you should specify the type.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJitendra VyasView Question on Stackoverflow
Solution 1 - CssNathan MacInnesView Answer on Stackoverflow
Solution 2 - CssSanoojView Answer on Stackoverflow
Solution 3 - CssŠime VidasView Answer on Stackoverflow
Solution 4 - CsscHaoView Answer on Stackoverflow