X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

HTML <script> type Attribute

HTML script Tag Reference HTML <script> tag

Example

A script with the type attribute specified:

<script type="text/javascript">
document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script>

Try it Yourself »

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The type attribute is supported in all major browsers.


Definition and Usage

The type attribute specifies the MIME type of a script.

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

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


Differences Between HTML 4.01 and HTML5

In HTML5, the type attribute is no longer required. The default value is "text/javascript".


Syntax

<script type="MIME_type">

Attribute Values

Value Description
MIME_type Specifies the MIME type of the script.

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

Look at IANA MIME types for a complete list of standard MIME types.



HTML script Tag Reference HTML <script> tag

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook