HTML and script and type properties

HTML script type attribute HTML and script.html

The type property gives the language of the script or the format of the data. If the property exists, its value must be a valid MIME type.

Script with specified type property:

<script type="text/javascript">
document.write("Hello World!");
</script>

Try it out . . .

Browser support

HTML script type attribute HTML script type attribute HTML script type attribute HTML script type attribute HTML script type attribute

The type property is supported by all major browsers.


Definitions and usages

The type property specifies the MIME type of the script.

The type property identifies the content between the label and the label.

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


The difference between HTML 4.01 and HTML5

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


Grammar

<script type="MIME_type">

The property value

value describe
MIME_type Specify the MIME type of the script.

Some common values:
  • Text / JavaScript (default)
  • text/ecmascript
  • application/ecmascript
  • application/javascript
  • text/vbscript

See IANA MIME type , Get a complete list of standard MIME types.



HTML script type attribute HTML and script.html