Latest

recent

HTML Script type attribute

Example

Insert a JavaScript in an HTML page:
<script type="text/javascript">
document.write("Hello World!");
</script>


Definition and Usage

The required 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".

Browser Support

The type attribute is supported in all major browsers.

Syntax

<script type="value">

Attribute Values

Value Description
MIME_type The MIME type. Some values:
  • text/javascript
  • text/ecmascript
  • application/ecmascript
  • application/javascript
  • text/vbscript

Note: According to IANA, the "text/javascript" MIME type is obsolete. The new standard is "application/javascript". However, "application/javascript" is not supported by Internet Explorer.
HTML Script type attribute Reviewed by 1000sourcecodes on 21:04 Rating: 5
Powered by Blogger.