HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
  • Insights
  • Verify Certificate
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials

HTML5andCSS3.org helps developers learn modern frontend skills with practical tutorials, production-ready snippets, and fast web tools built for everyday coding.

Quick Links

  • About Us
  • Contact Us
  • Privacy Policy
  • Copyright
  • Disclaimer

Top Tools

  • Try It Editor
  • JSON Formatter
  • CSS Minifier
  • HTML Minifier
  • Base64 Encoder / Decoder

Contact

  • business@html5andcss3.org
Newsletter

Learn at your own pace, practice with useful tools, and build websites you're proud of.

© 2011-2026 html5andcss3.org. All rights reserved.

How to Use

HTML Tags

HTML Tags

HTML <!DOCTYPE> TagHTML <html> TagHTML <head> TagHTML <title> TagHTML <body> TagHTML <base> TagHTML <link> TagHTML <meta> TagHTML <style> TagHTML <script> TagHTML <h1 to h6> TagHTML <hgroup> TagHTML <p> TagHTML <br> TagHTML <wbr> TagHTML <hr> TagHTML <pre> TagHTML <b> TagHTML <strong> TagHTML <i> TagHTML <em> TagHTML <mark> TagHTML <small> TagHTML <del> TagHTML <ins> TagHTML <sub> TagHTML <sup> TagHTML <u> TagHTML <blockquote> TagHTML <q> TagHTML <cite> TagHTML <abbr> TagHTML <address> TagHTML <bdo> TagHTML <bdi> TagHTML <a> TagHTML <nav> TagHTML <ul> TagsHTML <menu> TagHTML <ol> TagHTML <dl> TagHTML <img> TagHTML <figure> TagHTML <figcaption> TagHTML <audio> TagHTML <video> TagHTML <source> TagHTML <track> TagHTML <embed> TagHTML <object> TagHTML <param> Tag (Obsolete)HTML <picture> TagHTML <canvas> TagHTML <map> TagHTML <area> TagHTML <table> TagHTML <caption> TagHTML <thead> TagHTML <tbody> TagHTML <tfoot> TagHTML <tr> TagHTML <th> TagHTML <td> TagHTML <col> TagHTML <colgroup> TagHTML <form> TagHTML <input> TagHTML <textarea> TagHTML <button> TagHTML <select> TagHTML <selectedcontent> TagHTML <option> TagHTML <optgroup> TagHTML <label> TagHTML <fieldset> TagHTML <legend> TagHTML <datalist> TagHTML <output> TagHTML <meter> TagHTML <progress> TagHTML <header> TagHTML <footer> TagHTML <article> TagHTML <section> TagHTML <aside> TagHTML <main> TagHTML <search> TagHTML <details> TagHTML <summary> TagHTML <dialog> TagHTML <time> TagHTML <noscript> TagHTML <slot> TagsHTML <template> TagHTML <shadow> Tag (Obsolete)HTML <center> TagHTML <font> TagHTML <big> TagHTML <strike> TagHTML <tt> TagHTML <acronym> TagHTML <applet> TagHTML <frame> TagHTML <frameset> TagHTML <noframes> TagHTML <marquee> TagHTML <blink> TagHTML <s> TagHTML <var> TagHTML <kbd> TagHTML <samp> TagHTML <code> TagHTML <dfn> TagHTML <div> TagHTML <span> TagHTML Comment TagHTML <data> TagHTML Ruby Annotations: <ruby>, <rt> and <rp>HTML <svg> TagHTML <basefont> Tag
  1. Home
  2. /
  3. Tutorials
  4. /
  5. HTML Tutorial
  6. /
  7. HTML <script> Tag

HTML Tags

HTML <script> Tag

The <script> tag is used to embed or reference JavaScript code in an HTML document.
It allows you to create interactive features, handle events, manipulate the DOM, and perform dynamic operations on a webpage.

Syntax

html

<script>
  // JavaScript code here
</script>

<!-- OR referencing an external file -->
<script src="script.js"></script>

Attributes

AttributeDescription
srcSpecifies the URL of an external script file.
typeSpecifies the scripting language. Default is text/javascript.
asyncLoads the script asynchronously without blocking HTML parsing.
deferLoads the script after the HTML is fully parsed.
crossoriginHandles CORS requests for external scripts.
nomodulePrevents execution in browsers that support ES modules.

Example

html

<!DOCTYPE html>
<html>
<head>
  <title>Script Tag Example</title>
  <script>
    function showMessage() {
      alert("Hello! This is a message from JavaScript.");
    }
  </script>
</head>
<body>
  <h1>Click the button to see the message</h1>
  <button onclick="showMessage()">Click Me</button>
</body>
</html>

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE9+
YesYesYesYesYesYes

The <script> tag itself is invisible, but it can execute code that displays alerts, modifies content, or responds to user actions.

Notes

  • The <script> tag can contain inline JavaScript or reference an external file.
  • async and defer help improve page load performance.
  • Scripts can be placed in <head> or at the end of <body> for faster rendering.
  • Always ensure scripts are properly secured to prevent XSS vulnerabilities.

Conclusion

The <script> tag is essential for adding dynamic behavior and interactivity to HTML pages.
Although it does not produce visual content directly, it powers most modern web functionality, making it a core element in web development.

PreviousHTML <style> TagNextHTML <h1 to h6> Tag