Skip to main content
HTML Validation

Bad value X for attribute “type” on element “script”: A JavaScript MIME type must not contain any characters after the subtype.

About This HTML Issue

The type attribute of a <script> element has extra text after its JavaScript MIME type, such as a ; charset=utf-8 parameter or a piece of another attribute.

When a <script> has a type, the HTML standard tells browsers to run it as JavaScript only if the value is exactly a JavaScript MIME type like text/javascript. Letter case and surrounding spaces don't matter, but parameters aren't allowed. Any other value turns the element into a data block, which the browser never runs. So a <script> with src often gets a second error too: data blocks can't have a src attribute.

There are two common causes. Older code sometimes copied ; charset=utf-8 from an HTTP Content-Type header, where parameters are allowed, into the type attribute, where they aren't. Or someone typed text/javascript" async="async into a CMS field or plugin setting that fills in type, hoping to add a second attribute. The template escaped the quotes as &quot;, so async stayed inside the type value.

For JavaScript, remove type. The default is already text/javascript, and the validator reports an explicit one as unnecessary. Write other options like async or defer as separate attributes. If the script file needs a declared encoding, set it in the Content-Type header the server sends for that file.

Invalid example

<script src="/js/app.js" type="text/javascript; charset=utf-8"></script>
<script src="/js/stats.js" type="text/javascript&quot; async=&quot;async"></script>

Valid example

<script src="/js/app.js"></script>
<script src="/js/stats.js" async></script>

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Help us improve our guides

Was this guide helpful?
🌍 Trusted by teams worldwide

Validate at scale.
Ship accessible websites, faster.

Automated HTML & accessibility validation for large sites. Check thousands of pages against WCAG guidelines and W3C standards in minutes, not days.

Scheduled Reports
API Access
Open Source Standards
€5 / week

1K Weekly

1,000 monthly checks. Cancel anytime.

Get 1K Weekly →

Join teams across 40+ countries