HTML Checking for Large Sites
Rocket Validator automatically checks your pages on the W3C Validator.
Bad value X for attribute “src” on element “img”: Illegal character in query
The src
attribute on an element <img>
contains a character that is not allowed, and should be encoded.
Some typical examples include the pipe character |
that should be replaced by its encoded alternative %7C
, and the left square bracket [
that needs to be encoded as %5B
.
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:
<img>
tags, used to include images on a document, require an alt
attribute to describe the contents of the image. This is essential for users that cannot see the image (like screen reader users), or as an alternate text when the image cannot be displayed. Example:
<img src="photo.jpg" alt="Person holding a cat" />
A start tag for <img>
has been found inside a <noscript>
section within the <head>
, where it’s not allowed. Consider moving it to the <body>
section.
The HTML <noscript>
element defines a section of HTML to be inserted if a script type on the page is unsupported or if scripting is currently turned off in the browser.
When JavaScript is disabled, the content inside <noscript>
will be used instead, so this content must fit within its parent section. As an <img>
tag is not allowed inside <head>
, this will raise an issue. Instead, consider moving the <noscript>
part to the <body>
section.
This issue is often related to 3rd party tracking pixels like the Facebook or LinkedIn conversion tracking pixels. For example, the Facebook pixel instructions tell you to insert it like this:
<html>
<head>
<script>
...some script...
</script>
<noscript>
<img src="..." />
</noscript>
</head>
<body>
...
</body>
</html>
Instead, consider moving the <noscript>
part inside the <body>
, where the <img>
makes sense to be inserted:
<html>
<head>
<script>
...some script...
</script>
</head>
<body>
...
<noscript>
<img src="..." />
</noscript>
</body>
</html>
Learn more:
An <iframe>
element allows to embed an HTML document inside another HTML document, and its src
attribute is indicated the source URL of the embedded web page. The src
attribute is a required attribute, so it cannot be blank.
Example:
<iframe src="https://example.com/map.html"></iframe>
Learn more:
The src
attribute on an <img>
element contains an invalid character, that should be properly encoded as a URI percent-encoded character.
Learn more:
The src
attribute for <img>
tags is required, to define the source of the image, like in this example:
<img src="photo.jpg" alt="wombat" />
The attributes width
and height
of <img>
elements expect a non-negative integer, so an empty string is not allowed. Either define the correct dimension, or remove this attribute.
Learn more:
The href
attribute on an element <a>
contains a character that is not allowed, and should be encoded.
Some typical examples include the pipe character |
that should be replaced by its encoded alternative %7C
, and the left square bracket [
that needs to be encoded as %5B
.
A tab character has been found in the domain part for an href
attribute, which is not allowed.
The href
attribute on an element <link>
contains a character that is not allowed, and should be encoded.
Some typical examples include the pipe character |
that should be replaced by its encoded alternative %7C
, and the left square bracket [
that needs to be encoded as %5B
.
An <iframe>
element allows to embed an HTML document inside another HTML document, and its src
attribute is indicated the source URL of the embedded web page. The query part of that URL contains one or more space characters, which are not allowed, for example:
<iframe src="https://maps.google.it/maps?q=2700 6th Avenue"></iframe>
You should properly escape all space characters as %20
like this:
<iframe src="https://maps.google.it/maps?q=2700%206th%20Avenue"></iframe>
Learn more:
The src
attribute on an element <img>
contains a {
curly bracket character, which is not allowed unless properly encoded.
Space characters are not allowed in src
attributes. Instead, they should be converted to %20
. In this example, the first line is invalid and the second is valid:
<img src="https://example.com/?s=some term" alt="description" />
<img src="https://example.com/?s=some%20term" alt="description" />
The src
attribute on an <img>
tag is not allowed to contain space characters. You should replace them with “%20
“.
The attributes width
and height
on <img>
elements define the dimensions of the image in CSS pixels, and expect a non-negative integer.
Learn more:
<img>
elements accept a width
attribute to specify the size in pixels. This value can only be an integer, it should not contain units or %
. If you need to specify a percentage width, you can do that with CSS:
<img src="photo.jpg" alt="red car" style="width:100%;">
The width
and height
attributes on <img>
and <iframe>
elements expect a digit to indicate the number of pixels. Ensure that this attribute contains only digits.
For example:
<!-- This is invalid because width is not a digit -->
<img width="225px" height="100px" alt="cat" src="cat.jpg" />
<!-- This is valid -->
<img width="225" height="100" alt="cat" src="cat.jpg" />
<img>
tags used to display images require the attribute src
to indicate the source of the image, for example <img src="/img/photo.jpg" />
.
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:
<img>
tags no longer accept a border
attribute. This can be defined using CSS instead, for example:
<img src="..." alt="..." style="border:0;" />
A single <img>
element is used to embed an image, so adding the img
role to it is redundant.
The ARIA img role can be used to identify multiple elements inside page content that should be considered as a single image. These elements could be images, code snippets, text, emojis, or other content that can be combined to deliver information in a visual manner, for example:
<div role="img" aria-label="Description of the overall image">
<img src="graphic1.png" alt="">
<img src="graphic2.png">
</div>
Learn more:
Check the HTMLImageElement.srcset guide to learn about the correct usage of the srcset
and sizes
attributes.
25,000 HTML checks per month. Is that enough for your site?
Save time using our automated web checker. Let our crawler check your web pages on the W3C Validator.