type (HTML attribute)
| Depr. | Version |
|---|---|
| No | HTML 4 |
| IE5.5+ | FF1+ | SA1.3+ | OP9.2+ | CH2+ |
|---|---|---|---|---|
| Full | Full | Full | Full | Full |
Syntax
Example
In this example, the
type is set to "text/css" to
indicate that the linked resource is a CSS style sheet:
<link rel="stylesheet" type="text/css" href="global.css" />
Description
type is
an optional attribute of the link element, that is used
to identify the MIME type of the linked resource. This attribute allows
the browser to ignore MIME types it doesn’t understand when deciding
whether to load a linked resource.
Care should be taken over
defining this attribute. Although it’s optional in the specification,
browsers may not load the resource if the type
attribute is missing or incorrect (for example, Firefox and Opera will not
load a stylesheet if the type is not
"text/css", but they will load it if the
type is missing entirely).
Value
In theory, any number of MIME types
could be applied as a value for this attribute, but the most common you’re
likely to encounter is "text/css", to describe a CSS
style sheet. (The "text/css" media type is defined in
RFC 2318..) Other commonly used values are
"text/xml" or "application/rss+xml"
for an Atom or RSS feed.
Compatibility
| Internet Explorer | Firefox | Safari | Opera | Chrome | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 8.0 | 1.0 | 1.5 | 2.0 | 3.0 | 3.5 | 1.3 | 2.0 | 3.1 | 4.0 | 9.2 | 9.5 | 10.0 | 2.0 |
| Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full |
All tested browsers support this attribute.
User-contributed notes
There are no comments yet.
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.