SyntaxStudy
Sign Up
HTML Beginner 3 min read

The HTML Script Tag

The Script Tag

The <script> tag embeds or links JavaScript in HTML. Without any attributes it blocks HTML parsing while the script downloads and runs.

Placing scripts at the end of <body> ensures the DOM is available before the script runs.

Example
<!-- Inline script -->
<script>
  console.log("Page loaded");
</script>

<!-- External script at end of body -->
<body>
  <h1>Hello</h1>
  <script src="app.js"></script>
</body>
Pro Tip

Place scripts at the bottom of <body> or use defer to avoid blocking page rendering.