HTML <script>タイプ属性

❮HTML<script>タグ

type属性が指定されたスクリプト:

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

定義と使用法

このtype属性は、スクリプトのタイプを指定します。

このtype属性は、タグ <script></script>タグの間のコンテンツを識別します。


ブラウザのサポート

Attribute
type Yes Yes Yes Yes Yes

構文

<script type="scripttype">

属性値

Value Description
scripttype Specifies the type of the script.

Some common values:
  • A JavaScript MIME type like: application/javascript (default) or application/ecmascript
  • module:
  • Another MIME type. src attribute will be ignored

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


❮HTML<script>タグ