<script> : Script element

Introduction

The <script> element in HTML is used to embed or reference executable code within an HTML document. This code is typically written in JavaScript, but it can also be written in other scripting languages such as TypeScript or VBScript (though the latter is not recommended due to security concerns and lack of support in modern browsers).

There are three main ways to use the <script> element:

1. Inline Script : We can write it in between the <body> tag of html.

Example:

Output :

In this example an alert is come.

2. Internal Script : We can write it in between the <head> tag of html.

Example:

Output :

In this example an alert is come.

3. External Script : We can write it in a new file like filename.js(sample) .

Example :

Make a base html file first.

And make a new file of JAVASCRIPT hello.js .

After making the JAVASCRIPT file link with the HTML document. By

And we can write it in between <body> as well as <head> tag in document.

Output :

In this example an alert is come.

These are the three types of <script> tag.

Leave a Comment