Please note, this is a STATIC archive of website www.w3schools.com from 05 May 2020, cach3.com does not collect or store any user information, there is no "phishing" involved.
THE WORLD'S LARGEST WEB DEVELOPER SITE

HTML <script> type Attribute

❮ HTML <script> tag

Example

A script with the type attribute specified:

<script type="application/javascript">
document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script>
Try it Yourself »

Definition and Usage

The type attribute specifies the Internet media type (formerly known as MIME type) of a script.

The type attribute identifies the content between the <script> and </script> tags.

The media type consists of two parts: one media type and one subtype. For JavaScript, the media type is "application/javascript".


Browser Support

Attribute
type Yes Yes Yes Yes Yes

Syntax

<script type="media_type">

Attribute Values

Value Description
media_type Specifies the Internet media type of the script.

Some common values:
  • application/javascript (default)
  • application/ecmascript

Look at IANA Media Types for a complete list of standard media types.


❮ HTML <script> tag