content logo

Learn HTML:

Html script tag

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


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

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



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
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