HTML <script> and its example

aimtocode

HTML <script>:

The HTML <script> tag is used for declaring a script within the HTML document. The <script> element either contains scripting statements, or it points to an external script file through the src attribute.


Script Example:

Output:

My first javaScript code


Script Attributes:

Attribute Value Description
async async Defines that the script is executed asynchronously. (For external scripts only).
Not supported in IE9 and older versions.
charset charset Defines character encoding, used in an external file with the JavaScript code.
defer defer Defines, that the script must be executed after the loading of the page. (For external scripts only).
src URL Defines the URL of an external file with the JavaScript code. (Can be defined either relative, or an absolute URL).
type media_type Defines the MIME-type of the script.

aimtocode