HTML Script Tag Example


The HTML <script> tag is used to define as javascript within your HTML document. the client-side javascript is used in form validation, animation, and image manipulation, etc.

The Script Tag Attribute

Tag Description
async It is used to specify the script is executed asynchronously.
charset It is used to specify the character encoding used in an external script file.
defer It is used to specify that the script is executed when the page has finished parsing.
src It is used to specify the URL of an external script file.
type It is used to specify the media type of the script.
Syntax
<script> Here Script Contents... </script>
Example
<!DOCTYPE html>
<html>
   <head>
      <title>HTML Script Tag</title>
   </head>
   <body>
      <script type = "text/JavaScript">
         alert("welcome to our website");
      </script>
   </body>
</html>