type (HTML attribute)

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

Syntax

type="MIME type"

Description

In HTML 4, the method for identifying the composition of the script element’s contents was tidied up. The undefined language attribute was pushed aside for the type attribute, which is a required attribute.

Example

In this example, the type attribute identifies the script as plain text content comprising JavaScript code:

<script type="text/javascript" src="/scripts/complex.js"></script>

Value

Instead of specifying a scripting language and versions (as does the language attribute), the type attribute requires a MIME type, which consists of a media type and subtype. In the case of JavaScript, the MIME type would be "text/javascript".

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
Partial Partial Partial Partial Full Full Full Full Full Full Full Full Full Full Full Full Full

A small issue surrounds this attribute, or rather the attribute value shown in the example above ("text/javascript"). According to RFC 4329, the "text/javascript" media type is obsolete and should be replaced by "application/javascript". However, the latter isn’t supported by any version of Internet Explorer at the time of writing.

User-contributed notes

There are no comments yet.

Related Products