HTML Checking for Large Sites
Rocket Validator automatically checks your pages on the W3C Validator.
Stray start tag “script”.
A <script>
start tag has been found in an unexpected place in the document structure. Check that the <script>
section appears within the <head>
or <body>
sections.
Here’s an example of a script inserted in the head of the document:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<script>
console.log("Hello from the head");
</script>
</head>
<body>
<p></p>
</body>
</html>
Learn more:
Related W3C validator issues
The <script>
tag allows authors to include dynamic scripts and data blocks in their documents. When the src
is present, this tag accepts a type
attribute which must be either:
- an empty string
-
text/javascript
(that’s the default, so it can be omitted) -
module
Examples:
<!-- This is valid, without a type it defaults to JavaScript -->
<script src="app.js"></script>
<!-- This is valid, but will warn that it can be omitted -->
<script type="text/javascript" src="app.js"></script>
<!-- An empty attribute is valid, but will warn that it can be omitted -->
<script type="" src="app.js"></script>
<!-- The module keyword is also valid as a type -->
<script type="module" src="app.js"></script>
<!-- Any other type is invalid -->
<script type="wrong" src="app.js"></script>
<script type="text/html" src="app.js"></script>
<script type="image/jpeg" src="app.js"></script>
Learn more:
The value rocketlazyloadscript
used in a <script>
tag is not a valid one according to the HTML specification. It is introduced by the WP Rocket Wordpress extension.
Learn more:
The async
and defer
boolean attributes of the <script>
element control how an external script should be executed once it has been downloaded. The async
attribute makes sense when an external script (defined with the src
attribute) is loaded, or when defining a script of type module
:
<script async src="app.js"></script>
<script type="module">
/* JavaScript module code here */
</script>
Learn more:
The charset
attribute on a <script>
element can be used to specify the character encoding of an external script, whose URL should be specified on the src
attribute.
If the script is not external, then the charset
attribute should not be used, as the character encoding of the HTML document will be used.
Learn more:
The defer
and async
boolean attributes of the <script>
element control how an external script should be executed once it has been downloaded. These attributes only make sense when referring to external scripts, so a src
attribute must also be present to specify the location of the script.
Example:
<script defer src="app.js"></script>
If your script is not external, and is inlined within the HTML document, then you should remove the defer
attribute, like in this example:
<script>
console.log("hello");
</script>
Learn more:
And end tag has been found that does not match the current open element. Check the context to fix the start and end tags.
An <a>
tag can’t include other <a>
tags inside. Most probable cause is an unclosed <a>
tag, like in this example:
<a href="one.html">Page 1
<a href="two.html">Page 2</a>
HTML documents are expected to start with a first line containing the Document Type Declaration, that defines the HTML version used. Since HTML5, it’s just <!DOCTYPE html>
, which must appear before the start <html>
tag.
Here’s an example of a minimal HTML5 document:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<p></p>
</body>
</html>
All HTML documents must start with a <!DOCTYPE>
(Document Type Declaration), that informs browsers about the type and version of HTML used to build the document. In HTML5, this is simply <!DOCTYPE html>
and must appear at the start of the document.
Here is an example of a minimal HTML document, including the Document Type Declaration at its start:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<p></p>
</body>
</html>
An end tag for X has been found that does not correspond to a previous open tag. This usually happens when you close the same tag twice, for example:
<ul>
<li>item</li>
</ul>
</ul>
A <head>
start tag has been found in an unexpected place in the document structure. Check that the <head>
section appears before the <body>
section, and that is not duplicated.
The <head>
section of an HTML document is the container of metadata about the document, and must appear before the <body>
section. A common cause of this issue is duplicated <head>
sections.
Here is an example of a minimal HTML document structure:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<p></p>
</body>
</html>
A stray start tag <html>
has been found in the document. As this tag defines the start of the whole HTML document, it should appear only once.
A <style>
start tag has been found in an unexpected place in the document structure. Check that the <style>
section appears within the <head>
section.
Although in general it’s better to put your styles in external stylesheets and apply them using <link>
elements, CSS styles can also be included inside a document using the <style>
tag. In this case, it should be placed within the <head>
section, like in this example:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<style>
p {
color: #26b72b;
}
</style>
</head>
<body>
<p>This text will be green.</p>
</body>
</html>
Learn more:
A <script>
element has been found that is using the now obsolete charset
attribute. You can safely remove this attribute.
For example, this is using both type
and charset
attributes, with their default values. Both can be removed:
<script src="app.js" type="text/javascript" charset="UTF-8"></script>
and just use this:
<script src="app.js"></script>
Learn more:
The <script>
tag allows authors to include dynamic scripts and data blocks in their documents. This tag accepts two optional attributes, type
(which is unnecessary if it’s JavaScript, as that’s the default), and src
to indicate the URL of the external script to use.
The language
attribute is now obsolete and should not be used.
Read more about:
The default type
for <script>
tags is JavaScript
, so you don’t need to include the type for JS resources.
50,000 Accessibility and HTML checks per month. Fully automated.
Let our automated scanner check your large sites using Axe Core and W3C Validator.