content logo

Learn HTML:

Html script tag

The HTML <script> tag is used for declaring a script (such as JavaScript) within your HTML document.

Example

<!DOCTYPE html>
<html>
<head>
<title>HTML script Tag</title>
</head>
<body>
<script type="text/javascript">

      document.write("You're visiting tutorialspoint!")

</script>

</body>
</html>

This will produce following result:

You're visiting tutorialspoint!

For more detail on <script> tag please check HTML Scripts chapter.

 

Specific Attributes

The HTML <script> tag also supports following additional attributes:

Attribute Value Description
async  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
#HTML Script Example #HTML Script Code #HTML Script Tutorial