I was wondering whether or not it is necessary to use <link rel="stylesheet" type="text/css" href=...>
over <link rel="stylesheet" href=...>
. The rel="stylesheet"
marks the information that it is a stylesheet - so text/css
doesn't actually add anything as far as I'm concerned.
The only stylesheet format used by HTML is CSS anyway, so what does text/css
'say' to the browser? Some websites seem to add the type="text/css"
attribute (http://www.jquery.com/), whilst other ones don't (http://www.youtube.com/).
So, what is the use of type="text/css"
in a <link rel="stylesheet">
element, and is it necessary to include it?
The <link> tag defines the relationship between the current document and an external resource. The <link> tag is most often used to link to external style sheets or to add a favicon to your website. The <link> element is an empty element, it contains attributes only.
The type attribute identifies the content between the <style> and </style> tags. The default value is "text/css", which indicates that the content is CSS.
The type attribute applied to the style tag has only one acceptable value: text/css . In theory, other types of styling could also be used between style tags–thus the need for a type attribute.
It's not required with the HTML5 spec, but for older versions of HTML is it required.
Html 4 W3.org spec
http://www.w3.org/TR/html40/struct/links.html#edef-LINK http://www.w3.org/TR/html40/present/styles.html
Type stands for The MIME type of the style sheet. The only supported value I have ever seen is Text/CSS, which is probably why HTML5 has dropped it. I imagine they had it for earlier versions to allow future expansion possibilities which never happened.
Using HTML5 and not specifying the type, I have run so far into no problems with compatibility even when testing older versions of IE.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With