Computer >> Computer tutorials >  >> Programming >> Javascript

How to use the <script> tag to define client-side JavaScript?


The HTML <script> tag is used for declaring a script within your HTML document. Through this, you can define client-side JavaScript.

Here are the attributes of the <script> tag −

Attribute
Value
Description
async
async
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).

How to use the <script> tag to define client-side JavaScript?

Example

You can try to run the following code to learn how to use the <script> tag to define client-side JavaScript

<!DOCTYPE html>
<html>
   <head>
      <title>HTML script Tag</title>
   </head>
   <body>
      <script>
         document.write("Simple Easy Larning: Tutorialspoint!")
      </script>
   </body>
</html>