HTML script type property
Examples
With the specified type attribute script:
<script type="text/javascript">
document.write("Hello World!");
</script>
document.write("Hello World!");
</script>
try it"
Browser Support
All major browsers support the type attribute.
Definition and Usage
type attribute specifies the MIME type of the script.
type attribute identifies the <script> and </ script> content between the tags.
MIME type consists of two parts: media type and subtype. For JavaScript, MIME type is "text / javascript".
Differences between HTML 4.01 and HTML5
In HTML5, type attribute is no longer necessary. The default value is "text / javascript".
grammar
<script type="MIME_type">
Property Value
值 | 描述 |
---|---|
MIME_type | 规定脚本的 MIME 类型。 一些常用的值:
请参阅 IANA MIME 类型 ,获得标准 MIME 类型的完整列表。 |
HTML <script> tag