HTML <script> tag

Usage

Defines a script, for example JavaScript. Note that script commands should be surrounded by HTML comment tags so that the content is not displayed in older browsers which don't support scripting.

Example

Code:

<script type="text/javascript">
<!--
document.write("This is the script output!")
-->
</script>

Output:

Required Attributes

  • type - specifies the MIME type of the script

Optional Attributes

  • charset - specifies the character set used in the script
  • defer - indicates that the script will not generate any page content, and the browser can load the page as normal
  • src - specifies the URL location of the script

Core Attributes