type (HTML attribute)

Spec
Depr. Version
No HTML 4
Browser support (more…)
IE5.5+ FF1+ SA1.3+ OP9.2+ CH2+
Full Full Full Full Full

Syntax

type="MIME type"

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.

Related Products