Problem
I’m not sure if using link rel=”stylesheet” type=”text/css” href=…> over link rel=”stylesheet” href=…> is essential. As far as I’m concerned, the rel=”stylesheet” attribute indicates that it is a stylesheet, so text/css doesn’t add anything.
Because CSS is the only stylesheet format supported by HTML, what does text/css’say’ to the browser? Some websites (http://www.jquery.com/) appear to use the type=”text/css” attribute, but others (http://www.youtube.com/) do not.
So, what is the purpose of the type=”text/css” attribute in a link rel=”stylesheet”> element, and is it required?
Asked by pimvdb
Solution #1
It is not required by the HTML5 spec, however it is required by prior versions of HTML.
W3.org standard for HTML 4
http://www.w3.org/TR/html40/struct/links.html#edef-LINK http://www.w3.org/TR/html40/present/styles.html
The MIME type of the style sheet is represented by type. Text/CSS is the only supported value I’ve ever seen, which is probably why HTML5 removed it. I believe they had it for previous versions to enable for future expansion options that never materialized.
I’ve had no problems with compatibility using HTML5 and not defining the type, even when testing older versions of Internet Explorer.
Answered by Tom Gullen
Solution #2
No, it isn’t required.
The link element is the section of the HTML Living Standard that you’re interested in, and it states:
Answered by alexmuller
Solution #3
The type attribute on a link> tag is not required in HTML4.01. The type attribute is a tip to the browser, according to the specification. If the browser doesn’t recognize the hinted content type, it won’t fetch it.
Answered by Uyghur Lives Matter
Solution #4
It’s my understanding that it’s to allow stylesheets to be specified in formats other than text/css.
While that has been the dominant (and standard) delivery mechanism for stylesheets for (X)HTML pages, the specification is actually flexible enough to allow a range of additional MIME types to be sent; conventional browsers simply don’t support them.
Answered by GShenanigan
Solution #5
This type attribute isn’t significant to most individuals, however some systems (at least Microsoft SharePoint 2013) will use it when determining how to parse HTML (e.g. when creating a .master page file).
Answered by David Gilbertson
Post is based on https://stackoverflow.com/questions/5409114/is-type-text-css-necessary-in-a-link-tag