HTML <script> Tag:

The `<script>` tag in HTML is used to embed or reference JavaScript code within an HTML document. JavaScript is a scripting language that allows you to add dynamic behavior to web pages, enabling interactivity and manipulation of the document’s content.

Inline Script:

You can include JavaScript directly within the HTML document using inline scripts. Here’s an example:
html
<!DOCTYPE html>
<html lang=”en”>
<head>
  <meta charset=”UTF-8″>
  <meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
  <title>Inline Script Example</title>
</head>
<body>
  <h1>Inline Script Example</h1>
  <script>
    // JavaScript code goes here
    alert(‘Hello, World!’);
  </script>
</body>
</html>
Inline and External Script - Include JavaScript directly within the HTML document using inline scripts
Script Tag in HTML
In this example, the `<script>` tag contains JavaScript code that displays an alert when the page loads.

External Script:

You can also link to an external JavaScript file using the `src` attribute of the `<script>` tag. Create a separate `.js` file with your JavaScript code and include it in your HTML file like this:
script.js:
javascript
// JavaScript code
alert(‘Hello from external script!’);
index.html:
html
<!DOCTYPE html>
<html lang=”en”>
<head>
  <meta charset=”UTF-8″>
  <meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
  <title>External Script Example</title>
  <script src=”script.js”></script>
</head>
<body>
  <h1>External Script Example</h1>
</body>
</html>
In this example, the JavaScript code is placed in an external file (`script.js`), and the `<script>` tag with the `src` attribute is used to link to that file.
It’s common to include the `<script>` tag just before the closing `</body>` tag to ensure that the HTML content is loaded before the JavaScript code runs. Additionally, using external scripts helps keep your HTML file clean and separates concerns between markup and behavior.