D DevBrainBox

HTML5 Script

HTML

What is the <script> tag?

  • The <script> tag is used to embed or reference JavaScript code in an HTML document.
  • It can be placed in the <head> or <body> section.
  • JavaScript inside <script> runs on the client-side (browser).
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Script Example</title>
</head>
<body>
    <h1>Hello JavaScript!</h1>
    
    <script>
        document.querySelector("h1").style.color = "blue";
    </script>
</body>
</html>
  • The <script> tag contains JavaScript that changes the heading color to blue.

On this page