Html-script-tag

提供:Dev Guides
移動先:案内検索

HTML-<script>タグ

説明

HTML <script>タグは、HTMLドキュメント内でスクリプト(JavaScriptなど)を宣言するために使用されます。

<!DOCTYPE html>
<html>

   <head>
      <title>HTML script Tag</title>
   </head>

   <body>
      <script type = "text/JavaScript">
         document.write("You're visiting finddevguides!")
      </script>
   </body>

</html>

これは、次の結果を生成します-

<script>タグの詳細については、link:/html/html_javascript [HTML Scripts]の章を確認してください。

グローバル属性

このタグは、− link:/html/html_attributes_reference [HTML属性リファレンス]で説明されているすべてのグローバル属性をサポートします

特定の属性

HTML <script>タグは、次の追加属性もサポートしています-

Attribute Value Description
async html-5 sync Specifies that the script is executed asynchronously.
charset charset Defines the character encoding that the script uses.
defer defer Declares that the script will not generate any content. Therefore, the browser/user agent can continue parsing and rendering the rest of the page.
src URL Specifies a URI/URL of an external script.
type text/JavaScript application/ecmascript application/JavaScript text/vbscript Specifies the scripting language as a content-type (MIME type).
xml:space preserve Deprecated − Whether the whitespace in code should be preserved

イベント属性

このタグは、− link:/html/html_events_reference [* HTMLイベントリファレンス*]で説明されているすべてのイベント属性をサポートします

ブラウザのサポート

Chrome Firefox IE Opera Safari Android
Yes Yes Yes Yes Yes Yes