HTML Guide
The disabled attribute is a boolean attribute and must not have a value or should simply be present (disabled or disabled=""). Boolean attributes like disabled indicate presence by their occurrence alone and should not include explicit values.
Incorrect usage:
<input type="text" disabled="yes">
<input type="text" disabled="true">
<input type="text" disabled="false">
Correct usage:
<input type="text" disabled>
<input type="text" disabled="">
Only the presence of the disabled attribute disables the input. The value, if given, is ignored by the browser but causes validation problems if specified incorrectly. For W3C compliance, simply include the disabled attribute without specifying a value.
Although using <input type="text" disabled="disabled"> might still be marked as valid by the W3C Validator, the general recommendation for boolean attributes is to not pass any value.
The <label> element represents a caption in a document, and it can be associated with a form input using the for attribute, which must be an ID. Document IDs cannot contain whitespace.
Example:
<form>
<label for="user_name">Name</label>
<input type="text" id="user_name" />
</form>
Remove the unit; height on embed expects a non-negative integer (pixels) or a valid CSS length only when set via CSS, not the HTML attribute.
Detailed explanation
The embed element supports the presentational attributes width and height as unsigned integers representing CSS pixels. In HTML, the height attribute must be a number without a unit, for example 650. Supplying 650px violates the attribute’s value syntax and triggers the validator error.
If you want to use units or other CSS lengths (e.g., px, em, %, vh), set them with CSS via the style attribute or a stylesheet using the height property, not the HTML attribute.
HTML examples
Example reproducing the issue
<!DOCTYPE html>
<html lang="en">
<head>
<title>Embed height invalid</title>
</head>
<body>
<embed src="file.pdf" type="application/pdf" width="800" height="650px">
</body>
</html>
Corrected example (HTML attribute as integer)
<!DOCTYPE html>
<html lang="en">
<head>
<title>Embed height fixed</title>
</head>
<body>
<embed src="file.pdf" type="application/pdf" width="800" height="650">
</body>
</html>
Alternative corrected example (use CSS units)
<!DOCTYPE html>
<html lang="en">
<head>
<title>Embed height via CSS</title>
<style>
.viewer { width: 800px; height: 650px; }
</style>
</head>
<body>
<embed class="viewer" src="file.pdf" type="application/pdf">
</body>
</html>
The value used in the height attribute on element iframe is not a valid integer. Remove any leading or trailing spaces from the attribute value.
Here’s an example:
<iframe width="560" height="315" src="your-video-link" frameborder="0" allowfullscreen></iframe>
<video> elements accept a height attribute to specify the width in CSS 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.
Here’s an example of setting width and height on a video element.
<video controls width="640" height="480">
<source src="/media/cc0-videos/flower.webm" type="video/webm">
</video>
Backslashes (\) are not allowed in href values; use forward slashes (/) to separate path segments in URLs.
The href attribute in the a (anchor) element defines the hyperlink target and must contain a valid URL. According to the WHATWG HTML Standard, URL paths must use forward slashes (/) as delimiters, not backslashes (\). Backslashes are not recognized by web browsers as valid path separators and will cause validation errors or unexpected behavior. This issue often occurs when copying Windows file paths, which use backslashes, into HTML.
Incorrect HTML:
<a href="folder\page.html">Link</a>
Correct HTML:
<a href="folder/page.html">Link</a>
If you need to link to a file or resource, always replace any backslashes with forward slashes for proper HTML and browser compatibility.
The W3C HTML Validator issue you encountered indicates that the URL provided in the href attribute of an anchor (<a>) element is not formatted correctly.
How to Fix the Issue
- Check the Protocol: For a valid URL, make sure that after https: there are two slashes (//).
- Update the URL: Correct the URL format to include the missing slash.
Example of Incorrect HTML
Here is an example of the code that would trigger the validation error:
<a href="https:/example.comf">Example</a>
Corrected HTML
Here’s how the corrected code should look:
<a href="https://example.com">Example</a>
Summary
Make sure that all URLs within href attributes are correctly formatted with both slashes following the protocol (https:// or http://).
Curly braces {} are not allowed in the href attribute value of an <a> element because they are not permitted in valid URLs.
According to the HTML standard and URL specification, certain characters—including { and }—must be percent-encoded in URLs to avoid validation errors and ensure proper browser handling. If you need to include a curly brace in a URL, use percent-encoding: { is %7B and } is %7D.
Incorrect HTML:
<a href="http://example.com/?i=470722{0}">Link</a>
Correct HTML with percent-encoding:
<a href="http://example.com/?i=470722%7B0%7D">Link</a>
Resulting link:
http://example.com/?i=470722%7B0%7D
Only use plain { or } if you are generating URLs client-side (for example, as template placeholders in JavaScript). To validate properly, always encode or remove illegal characters in attribute values.
The href attribute in the a tag uses an invalid character, as > is not allowed in URL fragments.
According to the HTML standard and URL syntax, fragment identifiers (the part after #) can only contain certain characters. The > character is not permitted and must be removed or percent-encoded. If the > is unintentional, simply omit it; if it must be included as part of the fragment, encode it as %3E.
Original HTML (invalid):
<a href="/page.php>">Read more</a>
Corrected HTML (if > should not be present):
<a href="/page.php">Read more</a>
Corrected HTML (if > is required in fragment, encode it):
<a href="/page.php%3E">Read more</a>
Hash (#) characters can be used in an href attribute to link to a specific part of a document.
For example, if we have this page with several sections, each of them marked with an ID:
<h1>Frequently Asked Questions</h1>
<h2 id="pricing">Pricing</h2>
<p>All about pricing...</p>
<h2 id="terms">Terms</h2>
<p>You can find our terms at...</p>
<h2 id="guarantee">Guarantee</h2>
<p>We offer a guarantee...</p>
You can link to a specific part of that document, for example if this page URL is /faqs and you want to link to the Guarantee section you could use:
<a href="/faqs#guarantee">Guarantee</a>
Or, if you’re linking from inside the same document, for example in a table of contents, you could just use:
<a href="#guarantee">Guarantee</a>
As there can only be one fragment in an URL, the # character should only be used once. The following would be an invalid href:
<a href="/faqs#guarantee#pricing">Bad</a>
If needed, the # could be encoded as %23.
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 <a> tag contains an space, which is not allowed. Consider replacing space characters with “%20”.
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 attribute value in the href on the <a> element contains invalid characters.
HTML links require a valid URL as the value of the href attribute. Brackets ([, ]) are not allowed in attribute values.
Example of invalid usage:
<a href="mailto:[user@example.com]">Email Us</a>
Correct usage:
<a href="mailto:user@example.com">Email Us</a>
If you are using a template variable to create the links, be sure the template engine properly outputs a valid address in the final HTML.
Example using pseudocode for a templating engine (replace with your syntax as needed):
<a href="mailto:{{ address }}">Email Us</a>
Correct, fully rendered HTML after the template variable is replaced:
<a href="mailto:user@example.com">Email Us</a>
A space in the href URL wasn’t percent-encoded, making the link invalid.
The href attribute must contain a valid URL. Spaces and certain characters are not allowed in URLs and must be percent-encoded. In paths and query strings, replace spaces with %20 (or use + only in application/x-www-form-urlencoded query values, not paths).
Prefer generating properly encoded URLs server-side or via encodeURI/encodeURIComponent in JS. For fragment-only links, use href="#id". Avoid unencoded spaces anywhere after the scheme (e.g., https: or mailto:).
HTML Examples
Invalid (reproduces the validator error)
<a href="https://example.com/files/My File.pdf">Download</a>
Fixed (spaces percent-encoded)
<a href="https://example.com/files/My%20File.pdf">Download</a>
An href attribute on an a element contains an invalid URL that has space characters in the domain.
The domain in a URL cannot contain space characters, for example the following are invalid:
<a href="http://my domain.com">link</a>
<a href="http://my%20domain.com">link</a>
A tab character has been found in the domain part for an href attribute, which is not allowed.
URLs need to be encoded so that special characters area escaped, for example space characters need to be converted to “%20”. All special characters will therefore be converted to a percent sign followed by two hexadecimal characters, to be later decoded. In case a percentage sign (%) is found without being followed by two hexadecimal digits, a decoding error will be raised.
The most probable cause is an URL that contains a % that has not been properly encoded to %25 which is the code for the percent sign. For example:
<!-- This is invalid as the percentage sign has not been properly encoded -->
<a href="https://example.com?width=48%">link</a>
<!-- This is valid as the percentage sign has been encoded as %25 -->
<a href="https://example.com?width=48%25">link</a>
The at symbol (@) should be percent-encoded as %40 in order to include it at an href attribute.
An href attribute with the value http:// is not a valid URL because the host section is missing.
The href attribute in the area element must contain a valid URL. A URL requires a scheme (http or https), followed by ://, and then a valid host (such as example.com). The value http:// lacks a host, making it invalid according to URL standards and resulting in a validation error. If you don’t want the area to navigate anywhere, you can use href="#" for a placeholder or omit the href attribute entirely. To link to an actual location, provide the complete URL, including the host.
Invalid example:
<map name="myMap">
<area shape="rect" coords="30,23,183,191" href="http://" alt="" >
</map>
Valid example with a real host:
<map name="myMap">
<area shape="rect" coords="30,23,183,191" href="http://example.com/" alt="" >
</map>
Valid example with a placeholder, no navigation:
<map name="myMap">
<area shape="rect" coords="30,23,183,191" href="#" alt="" >
</map>
Replace http:// with a full URL or a suitable placeholder as needed for your application.
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.
A <pattern> element has been found with an invalid ID. Check the format of the ID and ensure it does not start with a digit, full stop (.) or hyphen (-).
The <pattern> element is used within <svg> elements, which use XML 1.0 syntax. That syntax specifies that valid IDs only include designated characters (letters, digits, and a few punctuation marks), and do not start with a digit, a full stop (.) character, or a hyphen-minus (-) character.
The value assigned to the integrity attribute in your script tag is not a valid base64-encoded string, which is required for Subresource Integrity (SRI).
The integrity attribute is used to ensure that the resource fetched by the browser matches the expected cryptographic hash. This value needs to be a valid base64-encoded hash, commonly generated using SHA-256, SHA-384, or SHA-512. The value format should be: [algorithm]-[base64-encoded hash]. The base64 part must have a length that is a multiple of 4, padded with = if necessary.
Example of incorrect usage:
<script
src="https://example.com/script.js"
integrity="sha384-BadBase64Value!"
crossorigin="anonymous"></script>
How to fix:
Obtain the correct hash for the file and use a valid, properly padded base64 value. You can generate an SRI hash using tools such as SRI Hash Generator or the command line.
Correct usage example:
<script
src="https://example.com/script.js"
integrity="sha384-oqVuAfXRKap7fdgcCY5uykM6+R9Gh8S7f1bE0q/PuF3LtHac+obYTK2B69B1a8tT"
crossorigin="anonymous"></script>
Always ensure the hash matches the actual file to avoid browser blocking, and that the base64 string is correctly formatted.
The specified language code in the lang attribute of the <html> tag is not a valid ISO code.
The loading attribute on the img element only accepts the values eager or lazy.
The loading attribute is used to specify lazy loading behavior for images and only accepts the values "lazy" or "eager" (which is the default).
Explanation:
- The loading attribute hints to the browser whether to load the image immediately ("eager"), defer until it reaches a calculated distance from the viewport ("lazy").
- Using values other than "lazy", "eager" results in validation errors and browsers ignore the attribute.
- Never use numeric values or case-variants; always use the lower-case string values above.
Incorrect Example:
<img src="logo.png" alt="Company logo" loading="1">
Correct Example:
<img src="logo.png" alt="Company logo" loading="lazy">
Replace the incorrect value with loading="lazy" or loading="eager", or remove the attribute, to resolve the validator issue.