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

JavascriptWeb DevelopmentFront End Scripts

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

Example

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

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <title>HTML script Tag</title>
   </head>
   <body>
      <script>
         document.write("Simple Easy Larning: Tutorialspoint!")
      </script>
   </body>
</html>
raja
Ali
Published on 08-Feb-2018 07:10:32
Advertisements