It is well known that in HTML5 you don’t need to specify the type attribute of
type="text/css" when you link to a CSS file. For example:
<link rel="stylesheet" href="stylesheet.css" type="text/css">
Instead, you can write something like:
<link rel="stylesheet" href="stylesheet.css"">
The HTML5 spec states:
The type attribute gives the MIME type of the linked resource. It is purely advisory. The value must be a valid MIME type. For external resource links, the type attribute is used as a hint to user agents so that they can avoid fetching resources they do not support. If the attribute is present, then the user agent must assume that the resource is of the given type (even if that is not a valid MIME type, e.g. the empty string). If the attribute is omitted, but the external resource link type has a default type defined, then the user agent must assume that the resource is of that type.
However, the W3C CSS validator seems to have some issues with HTML5 documents that exclude
type="text/css". See the two test pages below:
- HTML5 test 1 – type=”text/css” present – in this case the W3C validator finds the CSS file and validates it
- HTML5 test 2 – type=”text/css” not present – in this case the W3C validator cannot find the CSS file
Have you noticed this before? Have you found other instances where the missing
type="text/css" attribute is an issues?