- Attribute of
- <link> HTML Tag
- What does
- Describes the linked resource's media type (MIME type).
Specifying the Resource Type
type attribute of the
<link> element tells the browser what kind of resource you are linking to. The value of
type is a media type, formerly known as a MIME type.
The most common value of
type is perhaps
text/css, which is used when linking to an external stylesheet.
<link rel="stylesheet" type="text/css" href="http://mysite.com/styles.css">
You can specify any media type listed in the IANA Media Types list. However, the type will only be valid if you have specified a value for the
href attribute (i.e. a document URL).
It's good practise to include the
type attribute, but it isn't obligatory.
If you omit the
type attribute, the browser will make an educated guess at the content type by looking at the
rel attribute instead. So it will assume the
text/css where the
rel attribute is
stylesheet, for example.
In most cases, you can safely omit
type without any negative consequences, but it's a good idea to specify it to avoid problems in the future.