Content · Web Development · HTML

HTML Script Type Values: Classic, Module, and Data Block

Learn the accepted values, browser behavior, and useful examples for Script Type Values: Classic, Module, and Data Block.

1 views Published Oct 19, 2026 Updated Oct 19, 2026 Admin

You may have seen a short HTML attribute change how a field, image, or link behaves. This guide is about Script Type Values: Classic, Module, and Data Block. The type attribute changes whether a script runs as classic JavaScript, as a module, or stores inert non-executable data.

The useful question is not simply “Which value should I memorize?” It is “What should people be able to do on this page?” First decide the goal, then choose an HTML value that matches it.

How the values work


Different values affect different parts of the browser. Read the example below, then compare its attributes with the browser behavior described in the next section. Values that look similar may serve very different purposes.

A practical example


<script defer src="app.js"></script>
<script type="module" src="app-module.js"></script>
<script type="application/json" id="settings">
    {"theme":"light","pageSize":10}
</script>

Understanding the code


Start by finding the attribute in the example. The HTML element tells the browser what kind of thing it is displaying; the attribute supplies an extra instruction or hint about that particular element. If you remove the attribute, the element usually still exists, but one part of its behavior may change.

Modules defer by default and use module scope; application/json does not execute. Inline JSON must be safely encoded to avoid prematurely ending a script element.

If a file path or form action appears in the code, it is an example project path. Create the matching file or server endpoint before expecting the complete behavior to work. This distinction is important: HTML describes the page, but it does not automatically build a server or create missing resources.

When to use it


Use Script Type only where its documented behavior helps someone complete a task. Ask whether the choice improves clarity, keyboard access, performance, or correct data collection. If an extra attribute has no clear purpose, leaving it out may be safer than relying on a poorly understood hint.

Try it yourself


Identify which script actually executes and which is only structured data.

Save the code in a local HTML file, open it in a current browser, and inspect the relevant control or request. When the feature depends on a server, use a small local development server rather than guessing from the source alone.

Common Beginner Mistakes


  • Modules defer by default and use module scope; application/json does not execute.
  • Assuming every browser provides identical controls or follows a hint in exactly the same way.
  • Copying a demonstration without providing the files or server behavior it expects.

Key Takeaways


  • Modules defer by default and use module scope; application/json does not execute.
  • Choose the value based on what the visitor needs to do, not only on how the source looks.
  • Test the result in the browser, including keyboard access and submitted values where relevant.
Share this resourceSend this page to someone who may find it useful.