HTML Guides for data block
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 defer attribute is invalid on a <script> element whose type marks it as a data block, because browsers never execute data blocks.
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 is never fetched or run. The most common example is application/ld+json structured data. Since nothing executes, there is nothing to defer, and the attribute is invalid.
This usually happens when a template or a performance plugin adds defer to every <script> tag on the page, including the data blocks.
Examples
Invalid: defer on a data block
<script type="application/ld+json" defer>
{
"@context": "https://schema.org",
"@type": "Organization",
"name": "Example"
}
</script>
Valid: data block without defer
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Organization",
"name": "Example"
}
</script>
Remove the defer attribute. If the script was actually meant to run, fix the type value instead: use a JavaScript MIME type, module, or omit the attribute entirely.
The src attribute is invalid on a <script> element whose type marks it as a data block, because the data lives in the element itself and there is nothing to fetch from elsewhere.
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 is never downloaded or run. The most common example is application/ld+json structured data. The whole point of a data block is that it carries its content between the opening and closing tags, so pointing src at an external file makes no sense and is not allowed.
This usually happens when the type is set for a data block but the markup was copied from a real external script that still carries its src.
Examples
Invalid: src on a data block
<script type="application/ld+json" src="https://example.com/data.json"></script>
Valid: data block with inline content
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Organization",
"name": "Example"
}
</script>
Remove the src attribute and place the data inline. If the file really is a script to load and run, fix the type value instead: use a JavaScript MIME type, module, or omit the attribute entirely.
The async attribute is invalid on a <script> element whose type marks it as a data block, because browsers never fetch or execute data blocks.
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 is never downloaded or run. The most common example is application/ld+json structured data. async controls when a script downloads and executes, so it has no meaning on an element that does neither.
This usually happens when a template or a performance plugin adds async to every <script> tag on the page, including the data blocks.
Examples
Invalid: async on a data block
<script type="application/ld+json" async>
{
"@context": "https://schema.org",
"@type": "Organization",
"name": "Example"
}
</script>
Valid: data block without async
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Organization",
"name": "Example"
}
</script>
Remove the async attribute. If the script was actually meant to run, fix the type value instead: use a JavaScript MIME type, module, or omit the attribute entirely.
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.
Pro Trial
Full Pro access. Cancel anytime.
Start Pro Trial →Join teams across 40+ countries