HTML Guides for crossorigin
Learn how to identify and fix common HTML validation errors flagged by the W3C Validator — so your pages are standards-compliant and render correctly across every browser. Also check our Accessibility Guides.
The crossorigin attribute is invalid on a <script> element whose type marks it as a data block, because browsers never fetch a data block over the network.
When the type attribute is anything other than a JavaScript MIME type, module, importmap, or speculationrules, the browser treats the element as a data block: inline content that other scripts on the page can read, but that never runs. The most common example is application/ld+json structured data. A data block can't have a src attribute either, so the browser makes no request for it.
crossorigin sets the CORS mode the browser uses when it downloads an external script, and for classic scripts it also decides whether error details from another origin reach window.onerror. With no download and no execution, the attribute has nothing to apply to.
This usually happens when a build step or plugin adds crossorigin to every <script> tag on the page, including the data blocks.
Invalid example
<script type="application/ld+json" crossorigin="anonymous">
{
"@context": "https://schema.org",
"@type": "Organization",
"name": "Example"
}
</script>
Valid example
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Organization",
"name": "Example"
}
</script>
<script src="https://cdn.example.com/app.js" crossorigin="anonymous"></script>
Remove crossorigin from the data block and keep it on the scripts the browser actually downloads. If the element was meant to run, fix the type instead: use module, a JavaScript MIME type such as text/javascript, or leave type out.
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.
1K Weekly
1,000 monthly checks. Cancel anytime.
Get 1K Weekly →Join teams across 40+ countries