HTML Checking for Large Sites
Rocket Validator automatically checks your pages on the W3C Validator.
Bad value X for attribute “href” on element “link”: Illegal character in query
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
.
Related W3C validator issues
A <link>
element has been found in an invalid body context. Check the attributes of the <link>
element and ensure it’s not within the <body>
section.
If the element is within the <head>
section, it may have been interpreted as a body
context depending on previous elements. For example, while this <link>
element is valid per se and is in the <head>
section, it is deemed invalid because the previous <img>
element made the validator consider it a body
context:
<!DOCTYPE html>
<html lang="">
<head>
<title>Test</title>
<img src="photo.jpg" alt="A smiling cat" />
<link rel="canonical" href="https://example.com/" />
</head>
<body>
<p>Some content</p>
</body>
</html>
If we fix that document and move the <img>
tag within the body, the issue raised about <meta>
disappears because it’s now in a valid context:
<!DOCTYPE html>
<html lang="">
<head>
<title>Test</title>
<link rel="canonical" href="https://example.com/" />
</head>
<body>
<p>Some content</p>
<img src="photo.jpg" alt="A smiling cat" />
</body>
</html>
Learn more:
A <link>
element that is using the preload
value in the rel
attribute is missing the as
attribute, used to indicate the type of the resource.
The preload
value of the <link>
element’s rel
attribute lets you declare fetch requests in the HTML’s <head>
, specifying resources that your page will need very soon, which you want to start loading early in the page lifecycle, before browsers’ main rendering machinery kicks in. This ensures they are available earlier and are less likely to block the page’s render, improving performance.
The as
attribute specifies the type of content being loaded by the <link>
, which is necessary for request matching, application of correct content security policy, and setting of correct Accept
request header.
Learn more:
An <a>
element has been found with an invalid href
attribute, containing more than one #
adjacent character.
The #
is used to separate the fragment part of an URI (typically used to indicate a section within a document). For example, this is a valid link to a URI containing a fragment:
<a href="https://example.com/faqs#pricing">pricing</a>
The next example is invalid because it contains two adjacent #
characters, so that the fragment part would be #pricing
instead of pricing
:
<a href="https://example.com/faqs##pricing">pricing</a>
Learn more:
The href
attribute of an <a>
element contains an invalid character, that should be properly encoded as a URI percent-encoded character.
Learn more:
The href
attribute on the link
element must not be empty.
The href
attribute on an a
tag expects a valid URL, but only http://
was found.
<a>
tags can be used to link to an email address using the mailto
protocol in the href
attribute. Ensure that there is no space in the email address.
<a href="mailto: liza@example.com">This is wrong as it contains an space</a>
<a href="mailto:liza@example.com">This is OK</a>
The href
attribute on an <a>
link contains a space character, which is not allowed. If you’re trying to link to a phone URL, review the href
attribute to remove unallowed characters, as in this example:
<!-- Invalid as it contains a space character -->
<a href="tel: +123456789">call me</a>
<!-- Valid -->
<a href="tel:+123456789">call me</a>
Source:
Space characters are not allowed in href
attributes. Instead, they should be converted to %20
. In this example, the first line is invalid and the second is valid:
<a href="https://example.com#some term">invalid</a>
<a href="https://example.com#some%20term">valid</a>
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
.
The href
attribute on an <a>
tag contains an space, which is not allowed. Consider replacing space characters with “%20”.
A tab character has been found in the domain part for an href
attribute, which is not allowed.
The at symbol (@
) should be percent-encoded as %40
in order to include it at an href
attribute.
The media
attribute on a <link>
element has not been recognized.
This attribute specified what media the linked resource is optimized for. As an example, the following will link a general stylesheet, and a specific one for printing:
<head>
<link rel="stylesheet" type="text/css" href="general.css">
<link rel="stylesheet" type="text/css" href="print.css" media="print">
</head>
Valid values for this attribute include:
all
. Default, used for all media.
print
. Used for printers and print previews.
* screen
. Used for computer, tablets or smartphone screens.
Learn more:
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
.
The value used to define the type
of a link
is not valid. You’re probably using a URL instead of a valid type.
Example of a valid type
:
<link rel="icon" type="image/png" href="favicon.png">
Read more:
The <a>
element requires either a href
attribute, or a role
attribute.
Learn more:
50,000 Accessibility and HTML checks per month. Fully automated.
Let our automated scanner check your large sites using Axe Core and W3C Validator.