HTML Guides
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.
In the structure of a URL, the @ symbol has a special meaning: it separates the userinfo component (username and password) from the host. A URL with credentials follows this pattern:
scheme://username:password@hostname/path
When the username or password itself contains an @ character — for example, an email address used as a username — the browser or URL parser may not be able to determine where the credentials end and the hostname begins. For instance, in http://user@name:pass@example.com, it's unclear whether the host is name or example.com.
The URL Standard (maintained by WHATWG) requires that any @ appearing within the userinfo component be percent-encoded as %40. Percent-encoding replaces the literal character with a % followed by its hexadecimal ASCII code (40 for @). This removes the ambiguity and ensures all parsers interpret the URL identically.
While modern browsers may attempt to handle ambiguous URLs, the behavior is not guaranteed to be consistent across all user agents, link checkers, or HTTP clients. Properly encoding these characters ensures reliable behavior everywhere and keeps your HTML valid.
Note: Including credentials directly in URLs is generally discouraged for security reasons, as they may be exposed in browser history, server logs, and referrer headers. Consider alternative authentication methods when possible.
Examples
❌ Incorrect: unencoded @ in the username
<a href="http://user@name:password@example.com/path">Login</a>
Here, the parser cannot reliably distinguish user@name as the username from the @ that separates credentials from the host.
✅ Correct: percent-encoded @ in the username
<a href="http://user%40name:password@example.com/path">Login</a>
The @ within the username is encoded as %40, leaving only one literal @ to serve as the delimiter before the hostname.
❌ Incorrect: unencoded @ in the password
<a href="http://admin:p@ss@example.com/dashboard">Dashboard</a>
✅ Correct: percent-encoded @ in the password
<a href="http://admin:p%40ss@example.com/dashboard">Dashboard</a>
❌ Incorrect: email address used as username without encoding
<a href="ftp://joe@example.org:secret@ftp.example.com/files">Files</a>
✅ Correct: email address with @ percent-encoded
<a href="ftp://joe%40example.org:secret@ftp.example.com/files">Files</a>
To fix this issue, identify every @ character that appears before the final @ in the authority section of the URL and replace it with %40. The last @ in the authority is the actual delimiter and must remain as a literal character.
The path in an <area> element's href can't contain a literal space, so write each space as %20 or take it out of the URL.
An <area> defines one clickable region of an image map. The <map> element groups the areas under a name, and an <img> points to that map with usemap="#name". An <area> with an href is a link, and the URL Standard doesn't allow spaces anywhere in a URL path. The usual cause is a page or file name with a space in it, like /islands/north island.
Browsers percent-encode the space before following the link, so the click usually still works. A crawler or a script that reads the raw value may not, and the markup is invalid either way.
Replace each space with %20. If you control the target URLs, hyphens (north-island) make cleaner addresses that need no encoding at all. A space after the ? triggers a different message, Illegal character in query, and %20 fixes that one too.
Every <area> with an href also needs an alt attribute. Screen readers announce it as the link text for that region, and the validator reports a missing one as a separate error.
Invalid example
<img src="islands.png" alt="Map of the islands" usemap="#islands" width="600" height="400">
<map name="islands">
<area shape="rect" coords="20,40,180,160" href="/islands/north island" alt="North Island">
<area shape="rect" coords="220,200,400,320" href="/islands/south island" alt="South Island">
</map>
Valid example: spaces encoded as %20
<img src="islands.png" alt="Map of the islands" usemap="#islands" width="600" height="400">
<map name="islands">
<area shape="rect" coords="20,40,180,160" href="/islands/north%20island" alt="North Island">
<area shape="rect" coords="220,200,400,320" href="/islands/south%20island" alt="South Island">
</map>
Valid example: hyphens instead of spaces
<img src="islands.png" alt="Map of the islands" usemap="#islands" width="600" height="400">
<map name="islands">
<area shape="rect" coords="20,40,180,160" href="/islands/north-island" alt="North Island">
<area shape="rect" coords="220,200,400,320" href="/islands/south-island" alt="South Island">
</map>
The <area> element defines a clickable region within an <map> element, which is used with images to create image maps. When an <area> element includes an href attribute, the browser treats it as a hyperlink. The value of href must be a valid URL, and http:// alone fails validation because the URL specification requires a host after the :// separator. An empty host is not permitted.
This matters for several reasons. Browsers may handle malformed URLs unpredictably — some might ignore the link, others might attempt navigation to a nonsensical destination, and others might throw a network error. Screen readers and other assistive technologies rely on valid href values to announce links correctly and provide meaningful navigation to users. From a standards compliance perspective, the WHATWG URL Standard explicitly rejects URLs with empty hosts, and the W3C validator flags this as an error.
This issue commonly appears when placeholder URLs are left in during development, when CMS tools generate incomplete markup, or when a URL value is dynamically constructed but the host portion ends up empty.
How to fix it
- If the area should link somewhere, replace
http://with the full, intended URL including the host (e.g.,https://example.com/page). - If the area is a temporary placeholder, use
href="#"to create a valid no-op link, though be aware this will scroll the page to the top when clicked. - If the area shouldn't be interactive, remove the
hrefattribute entirely. Withouthref, the<area>element is not a hyperlink and won't be clickable.
Examples
Invalid: empty host in URL
The value http:// has no host, which triggers the validation error.
<img src="diagram.png" alt="Site map" usemap="#siteMap">
<map name="siteMap">
<area shape="rect" coords="30,23,183,191" href="http://" alt="Home page">
</map>
Fixed: complete URL with a valid host
Providing a full URL with a host resolves the error.
<img src="diagram.png" alt="Site map" usemap="#siteMap">
<map name="siteMap">
<area shape="rect" coords="30,23,183,191" href="https://example.com/" alt="Home page">
</map>
Fixed: placeholder link with #
If you need the area to remain clickable but don't have a destination yet, href="#" is a valid placeholder.
<img src="diagram.png" alt="Site map" usemap="#siteMap">
<map name="siteMap">
<area shape="rect" coords="30,23,183,191" href="#" alt="Home page">
</map>
Fixed: non-interactive area without href
If the area doesn't need to be a link, simply omit the href attribute.
<img src="diagram.png" alt="Site map" usemap="#siteMap">
<map name="siteMap">
<area shape="rect" coords="30,23,183,191" alt="Home page">
</map>
Spaces in the href attribute of a <link> element are not valid URL characters and must be encoded as %20.
URLs follow the syntax defined in RFC 3986, which does not allow literal space characters in any component of a URI. The <link> element points to external resources such as stylesheets, icons, and preloaded files, and its href must be a valid URL. A browser often corrects the space on its own, but the markup is still invalid, so the validator flags it.
To fix the issue, replace each space in the URL with %20, the percent-encoded form of the space character. If the resource genuinely lives at a path that contains spaces, the encoding is still required for the reference to be valid.
This often appears with files whose names contain spaces, like an icon exported as Capture 2026-06-23.webp, or with folder names that include spaces.
HTML examples
Invalid: space in href
<link rel="icon" href="https://example.com/files/Capture 2026-06-23.webp">
Valid: spaces encoded as %20
<link rel="icon" href="https://example.com/files/Capture%202026-06-23.webp">
If you control the file or directory names, renaming them to avoid spaces is a simpler long term fix. Use hyphens or underscores instead:
<link rel="icon" href="https://example.com/files/capture-2026-06-23.webp">
A URL can't have [ or ] in its path, so the href of a <link> element needs them percent-encoded as %5B and %5D, or removed.
The URL Standard only allows square brackets around an IPv6 address in the host, as in http://[2001:db8::1]/. In the path they are invalid. The validator reports only the first bad character in each URL, and a ] with no [ before it gets the same error with ] in the message. In the query string, after the ?, the validator reports brackets as "Illegal character in query" instead.
In a <link>, the brackets often come from a template placeholder that never got replaced. Some content management systems, Drupal among them, write tokens in square brackets, such as [site:url], and swap them for real values when the page renders. If the token is misspelled or the module that fills it is turned off, the raw token ends up in the HTML. Browsers and search engines read it as a relative path and resolve it against the page's address, so a rel="canonical" link points to a URL that doesn't exist.
Fix the template so it prints the final URL. If the brackets really are part of a file name, encode them as %5B and %5D, or rename the file so the URL doesn't need them.
Invalid example
<link rel="canonical" href="[page:url]">
<link rel="stylesheet" href="/css/main[1].css">
Valid example
<link rel="canonical" href="https://example.com/about">
<link rel="stylesheet" href="/css/main%5B1%5D.css">
A | (pipe) character in a link element's href attribute is not valid in a URL because it is not a legal character in a query string without being percent-encoded.
This error commonly appears when loading multiple Google Fonts in a single <link> tag using the older Google Fonts API v1 syntax, which used the pipe character to separate font families:
fonts.googleapis.com/css?family=Open+Sans|Roboto
The | character must be encoded as %7C to be valid in a URL. However, even with encoding, the Google Fonts API v1 no longer supports loading multiple families this way. The current Google Fonts API v2 (/css2) uses separate family parameters instead.
Bad example
<link rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Open+Sans|Roboto">
Good example
Use the Google Fonts API v2 with separate family parameters:
<link rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Open+Sans&family=Roboto&display=swap">
If you are not using Google Fonts and cannot change the URL structure, percent-encode the pipe character:
<link rel="stylesheet"
href="https://example.com/css?param1=a%7Cparam2=b">
URLs used in HTML attributes must follow the URL Living Standard, which defines a specific set of characters that are allowed in each part of a URL. The query component of a URL — everything after the ? — permits most printable ASCII characters, but certain characters are still considered illegal and must be percent-encoded. When the W3C validator encounters one of these forbidden characters in the href of a <link> element, it raises this error.
Common characters that trigger this issue include:
| Character | Percent-encoded |
|---|---|
| ` | ` (pipe) |
[ (left bracket) | %5B |
] (right bracket) | %5D |
{ (left brace) | %7B |
} (right brace) | %7D |
^ (caret) | %5E |
` (backtick) | %60 |
| (space) | %20 |
Why this matters
While many modern browsers are lenient and will silently fix malformed URLs, relying on this behavior is risky. Invalid URLs can cause problems in several ways:
- Inconsistent browser behavior: Not all user agents handle illegal characters the same way, which can lead to broken stylesheets or resources failing to load.
- Interoperability issues: Proxies, CDNs, and other intermediaries may reject or mangle URLs with illegal characters.
- Standards compliance: Valid HTML requires valid URLs in attributes. An illegal character in the
hrefmakes the entire document non-conforming. - Copy-paste and sharing reliability: Malformed URLs are more likely to break when shared across systems, emails, or documentation.
How to fix it
Identify the illegal characters in your URL's query string and replace each one with its percent-encoded equivalent. If you're generating URLs programmatically, use a proper URL encoding function (e.g., encodeURIComponent() in JavaScript, urlencode() in PHP, or urllib.parse.quote() in Python) to ensure all special characters are encoded correctly.
Examples
❌ Illegal pipe character in the query string
This is a common pattern seen with Google Fonts URLs that use | to separate font families:
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans|Roboto">
✅ Pipe character percent-encoded
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans%7CRoboto">
❌ Square brackets in the query string
Some APIs or frameworks use bracket notation in query parameters:
<link rel="stylesheet" href="https://example.com/styles?themes[]=dark&themes[]=compact">
✅ Square brackets percent-encoded
<link rel="stylesheet" href="https://example.com/styles?themes%5B%5D=dark&themes%5B%5D=compact">
❌ Space character in the query string
<link rel="stylesheet" href="https://example.com/css?file=my styles.css">
✅ Space character percent-encoded
<link rel="stylesheet" href="https://example.com/css?file=my%20styles.css">
Note that for Google Fonts specifically, the modern API (v2) uses a different URL format that avoids the pipe character altogether. Where possible, consider updating to the latest version of an API rather than just encoding the old URL.
The http-equiv attribute contains a misspelled or invalid value.
The http-equiv attribute on the <meta> element acts as a pragma directive, simulating an HTTP response header. The HTML specification only allows a specific set of values for this attribute. The valid values include content-type, default-style, refresh, X-UA-Compatible, and content-security-policy.
The value X-UA-Compatible was historically used to tell Internet Explorer to use a specific rendering engine. While it's largely obsolete now that IE is no longer supported, the HTML spec still recognizes it as a valid value.
Common mistakes that trigger this error include:
- Typos like
X-UA-Complatible,X-UA-Compatable, orX-UA-Compatble - Using non-standard values like
imagetoolbar,cleartype, orcache-control - Using values that were valid in older HTML versions but are no longer recognized
HTML Examples
❌ Invalid: misspelled value
<meta http-equiv="X-UA-Complatible" content="IE=edge,chrome=1" />
✅ Valid: correctly spelled value
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
Note that the chrome=1 portion referenced Google Chrome Frame, a discontinued plugin. It's safe to remove it along with the entire <meta> tag if you no longer need to support Internet Explorer.
The <pattern> element lives inside <svg>, and SVG is an XML-based language. Unlike regular HTML — where id values follow relatively relaxed rules — SVG content must comply with XML 1.0 naming conventions. This means id values have stricter character and formatting requirements than you might be used to in plain HTML.
XML 1.0 Name Rules
An XML 1.0 name (used for id attributes in SVG) must follow these rules:
- First character must be a letter (
A–Z,a–z) or an underscore (_). - Subsequent characters can be letters, digits (
0–9), hyphens (-), underscores (_), or periods (.). - Spaces and special characters like
!,@,#,$,%,(,), etc. are not allowed anywhere in the name.
Common mistakes that trigger this error include starting an id with a digit (e.g., 1pattern), a hyphen (e.g., -myPattern), or a period (e.g., .dotPattern), or including characters like spaces or colons.
Why This Matters
- Standards compliance: SVG is parsed as XML in many contexts. An invalid XML name can cause parsing errors or unexpected behavior, especially when SVG is served with an XML MIME type or embedded in XHTML.
- Functionality: The
<pattern>element'sidis typically referenced viaurl(#id)infillorstrokeattributes. An invalididmay cause the pattern reference to silently fail, leaving elements unfilled or invisible. - Cross-browser consistency: While some browsers are lenient with invalid XML names, others are not. Using valid names ensures consistent rendering across all browsers and environments.
How to Fix
Rename the id value so it starts with a letter or underscore and contains only valid characters. If you reference this id elsewhere (e.g., in fill="url(#...)" or in CSS), update those references to match.
Examples
❌ Invalid: id starts with a digit
<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg">
<defs>
<pattern id="1stPattern" width="10" height="10" patternUnits="userSpaceOnUse">
<circle cx="5" cy="5" r="3" fill="blue" />
</pattern>
</defs>
<rect width="200" height="200" fill="url(#1stPattern)" />
</svg>
❌ Invalid: id starts with a hyphen
<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg">
<defs>
<pattern id="-stripe-bg" width="10" height="10" patternUnits="userSpaceOnUse">
<rect width="5" height="10" fill="red" />
</pattern>
</defs>
<rect width="200" height="200" fill="url(#-stripe-bg)" />
</svg>
❌ Invalid: id contains special characters
<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg">
<defs>
<pattern id="my pattern!" width="10" height="10" patternUnits="userSpaceOnUse">
<circle cx="5" cy="5" r="3" fill="green" />
</pattern>
</defs>
<rect width="200" height="200" fill="url(#my pattern!)" />
</svg>
✅ Valid: id starts with a letter
<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg">
<defs>
<pattern id="firstPattern" width="10" height="10" patternUnits="userSpaceOnUse">
<circle cx="5" cy="5" r="3" fill="blue" />
</pattern>
</defs>
<rect width="200" height="200" fill="url(#firstPattern)" />
</svg>
✅ Valid: id starts with an underscore
<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg">
<defs>
<pattern id="_stripe-bg" width="10" height="10" patternUnits="userSpaceOnUse">
<rect width="5" height="10" fill="red" />
</pattern>
</defs>
<rect width="200" height="200" fill="url(#_stripe-bg)" />
</svg>
✅ Valid: Using letters, digits, hyphens, and underscores
<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg">
<defs>
<pattern id="dot-grid_v2" width="10" height="10" patternUnits="userSpaceOnUse">
<circle cx="5" cy="5" r="3" fill="green" />
</pattern>
</defs>
<rect width="200" height="200" fill="url(#dot-grid_v2)" />
</svg>
Note that this same XML 1.0 naming rule applies to id attributes on all SVG elements — not just <pattern>. If you see similar errors on elements like <linearGradient>, <clipPath>, or <filter>, the same fix applies: ensure the id starts with a letter or underscore and uses only valid characters.
A <link> element has an imagesizes attribute, but at least one URL in its imagesrcset has no width descriptor such as 800w.
imagesrcset and imagesizes are the preload versions of the srcset and sizes attributes of <img>. On a <link rel="preload" as="image">, they let the browser start downloading the same file that the <img> will pick later.
imagesizes says how wide the image will be in the layout, and the browser compares that width with the w descriptor of each candidate to choose one. A URL with no descriptor gives it no width to compare, so when imagesizes is present, every candidate needs one. The message names "sizes" because the validator reuses its <img> wording.
This can come from a theme or plugin that preloads the main image of a page by copying the image's srcset into imagesrcset. When the image exists in only one size, that copy is a bare URL, but the plugin still prints imagesizes.
To fix it, add the width of each image file in pixels after its URL, as in hero.jpg 800w. If you preload a single file, you can also remove imagesrcset and imagesizes and put the URL in href instead. Density descriptors such as 2x won't work here either: next to imagesizes, the validator reports them as a different error.
Invalid example
<link
rel="preload"
as="image"
imagesrcset="hero.jpg"
imagesizes="(max-width: 800px) 100vw, 800px">
Valid example
<link
rel="preload"
as="image"
imagesrcset="hero.jpg 800w"
imagesizes="(max-width: 800px) 100vw, 800px">
The integrity attribute enables Subresource Integrity (SRI), a security feature that lets browsers verify that a fetched resource (such as a JavaScript file from a CDN) has not been tampered with. The attribute value follows the format [algorithm]-[base64-encoded hash], where the algorithm is typically sha256, sha384, or sha512, and the hash is a base64 representation of the file's cryptographic digest.
Base64 encoding works by converting binary data into a string of ASCII characters drawn from a 64-character alphabet. A key property of valid base64 is that the encoded output must always have a length that is a multiple of 4. When the raw binary data doesn't divide evenly, the output is padded with one or two = characters to reach the correct length. If the base64 string in your integrity attribute has an incorrect length — for instance, it was truncated, manually edited, or copied incompletely — the validator will flag it as invalid.
This matters for several reasons:
- Security: If the
integrityvalue is malformed, the browser cannot verify the resource. Depending on the browser, it may block the script entirely, breaking your site's functionality. - Standards compliance: The HTML specification requires the hash portion to be a valid base64 string. An invalid value is a conformance error.
- Reliability: A malformed hash will never match any file, so the SRI check will always fail, effectively making the script unusable.
Common causes of this error include:
- Copying the hash value incompletely (missing trailing
=padding or other characters). - Manually modifying the hash string.
- Using a tool that produced an incorrectly encoded output.
- Mixing up base64 and base64url encodings (base64url uses
-and_instead of+and/, and often omits padding).
To fix the issue, regenerate the correct SRI hash for the exact file being referenced. You can do this with the command line:
openssl dgst -sha384 -binary script.js | openssl base64 -A
Or using shasum and base64:
shasum -b -a 384 script.js | awk '{print $1}' | xxd -r -p | base64
Online tools like the SRI Hash Generator can also produce the correct value. After generating the hash, prepend the algorithm prefix (e.g., sha384-) and verify that the base64 portion has a length divisible by 4.
Examples
Incorrect: Malformed base64 value
The hash below is not a valid base64 string — its length is not a multiple of 4, and it contains the character !, which is not in the base64 alphabet.
<script
src="https://cdn.example.com/library.js"
integrity="sha384-BadBase64Value!"
crossorigin="anonymous"></script>
Incorrect: Truncated hash missing padding
This hash has been accidentally truncated, losing the trailing = padding characters that make it a valid base64 string.
<script
src="https://cdn.example.com/library.js"
integrity="sha384-oqVuAfXRKap7fdgcCY5uykM6+R9Gh8S7f1bE0q/PuF3LtHac+obYTK2B69B1a8t"
crossorigin="anonymous"></script>
Correct: Properly formatted SRI hash
The base64 hash is the correct length (a multiple of 4) and uses only valid base64 characters. The trailing T completes the final 4-character group without needing padding in this case, but other hashes may end with = or ==.
<script
src="https://cdn.example.com/library.js"
integrity="sha384-oqVuAfXRKap7fdgcCY5uykM6+R9Gh8S7f1bE0q/PuF3LtHac+obYTK2B69B1a8tT"
crossorigin="anonymous"></script>
Correct: Multiple hashes for fallback
You can provide multiple hash values separated by spaces. Each one must be independently valid base64 with the correct length.
<script
src="https://cdn.example.com/library.js"
integrity="sha256-BpfGp+xz0kN9mMKoECQbGRab7fMi/dsRZ7Sy7LVd3CE= sha384-oqVuAfXRKap7fdgcCY5uykM6+R9Gh8S7f1bE0q/PuF3LtHac+obYTK2B69B1a8tT"
crossorigin="anonymous"></script>
Always ensure the hash is generated from the exact file the src attribute points to. If the CDN serves a different version or a minified variant, the hash will not match, and the browser will block the resource regardless of whether the base64 encoding is valid.
The lang attribute on the <html> element tells browsers, screen readers, and search engines what language the page content is written in. Its value must follow the BCP 47 standard, which uses ISO 639 language codes as the primary language subtag. When the validator reports that a language subtag "is not a valid ISO language part of a language tag," it means the code you provided doesn't match any recognized language in the ISO 639 registry.
Common Causes
Typos in the language code
A simple misspelling like emg instead of en, or fre instead of fr, will trigger this error.
Using a country code instead of a language code
Country codes (ISO 3166) and language codes (ISO 639) are different standards. For example, uk is the country code for the United Kingdom, but it's also the valid language code for Ukrainian. Using gb (Great Britain) as a language would be invalid. Similarly, us is not a language code — you need en for English or en-US for American English specifically.
Using made-up or deprecated codes
Codes like xx, en-UK, or other non-standard values will fail validation. Note that while en-US and en-GB are valid (language-region format), en-UK is not because UK is not the correct ISO 3166-1 region subtag for the United Kingdom — GB is.
Why This Matters
- Accessibility: Screen readers rely on the
langattribute to select the correct pronunciation rules and voice profile. An invalid language code can cause assistive technology to mispronounce content or fall back to a default language. - SEO: Search engines use the
langattribute as a signal for serving the right content to users in the appropriate language and region. - Browser behavior: Browsers use the language tag for spell-checking, hyphenation, font selection, and other language-sensitive rendering decisions.
How to Fix It
- Identify the language your page is written in.
- Look up the correct ISO 639-1 two-letter code (preferred) or ISO 639-2 three-letter code for that language.
- If you need to specify a regional variant, append a hyphen and the ISO 3166-1 region code (e.g.,
pt-BRfor Brazilian Portuguese). - Replace the invalid value in the
langattribute.
Some commonly used valid language codes:
| Language | Code |
|---|---|
| English | en |
| English (US) | en-US |
| English (UK) | en-GB |
| Spanish | es |
| French | fr |
| German | de |
| Portuguese (Brazil) | pt-BR |
| Chinese (Simplified) | zh-Hans |
| Japanese | ja |
| Arabic | ar |
Examples
❌ Invalid: Typo in language code
<html lang="emg">
❌ Invalid: Country code used instead of language code
<html lang="us">
❌ Invalid: Incorrect region subtag
<html lang="en-UK">
❌ Invalid: Made-up language code
<html lang="english">
✅ Valid: Correct two-letter language code
<html lang="en">
✅ Valid: Language with region subtag
<html lang="en-GB">
✅ Valid: Full document with proper lang attribute
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Ma page</title>
</head>
<body>
<p>Bonjour le monde !</p>
</body>
</html>
You can verify your language tag using the IANA Language Subtag Registry or the BCP 47 Language Subtag Lookup tool to ensure your code is valid before updating your markup.
A lang value follows the BCP 47 format, where a four-letter subtag placed after the primary language is read as a script subtag from the ISO 15924 registry, and the validator reports "Bad script subtag" when that four-letter piece is not a registered script code.
In es-TRAD, the es part is a valid language subtag for Spanish, but TRAD has four letters, so the parser treats it as a script subtag. ISO 15924 has no Trad script, so the value fails validation. This usually happens when someone invents a code to express a "traditional" or regional variant instead of using a registered subtag.
Valid script subtags are exactly four letters with an initial capital, such as Latn (Latin), Cyrl (Cyrillic), Hans (Simplified Han), and Hant (Traditional Han). Most languages do not need one, because each language has a default script. You add a script subtag only when the text uses a script other than the default, as in zh-Hant for Traditional Chinese.
To fix the value, either use a registered ISO 15924 script subtag or drop the extra subtag and keep just the language code, with an optional region.
Invalid example
<span lang="es-TRAD">Español tradicional</span>
TRAD is read as a script subtag, and it is not a valid ISO 15924 code.
Valid example
<span lang="es">Español</span>
When you genuinely need to mark a script, use a registered ISO 15924 subtag:
<span lang="zh-Hant">繁體中文</span>
The first part of a lang value has to be a language code made of letters, like en or fr, and the validator rejects a wildcard, an underscore, a digit or a template placeholder in that position.
The lang attribute takes a BCP 47 language tag: subtags joined by hyphens, starting with the language subtag. That first subtag is almost always a two- or three-letter ISO 639 code like en, pt or ast, optionally followed by a region (en-GB), a script (zh-Hant) or other registered subtags. When the language subtag contains a character that isn't a letter, the validator reports it with this message. A code that has the right shape but isn't registered, such as zz, gets a different error saying it is not a valid ISO language part of a language tag.
A few patterns cause most of these errors. The * wildcard means "any language" in the Accept-Language HTTP header, but it isn't a language tag, and a template that prints a stored language setting can output it when content is marked as being for all languages. Locale names such as en_US or fr_FR use an underscore, which HTML doesn't accept as a separator, so the validator reads the whole value as one subtag and shows it in lowercase (fr_fr) in the message. Unreplaced placeholders like %LANG% or {lang} fail the same way.
Replace the value with the tag for the language the content is written in. On a multilingual page, put the main language on <html> and give passages in other languages their own lang. Screen readers use this value to pick a voice and pronunciation rules, and browsers use it for hyphenation and spell checking. Neither can do that with *.
Invalid example
The document language is a wildcard, and the French paragraph uses a locale name with an underscore:
<!DOCTYPE html>
<html lang="*">
<head>
<meta charset="utf-8">
<title>Opening hours</title>
</head>
<body>
<p>The library opens at 9:00 every weekday.</p>
<p lang="fr_FR">La bibliothèque ouvre à 9 h en semaine.</p>
</body>
</html>
Valid example
English on the root element, and a hyphenated tag for the French paragraph:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Opening hours</title>
</head>
<body>
<p>The library opens at 9:00 every weekday.</p>
<p lang="fr-FR">La bibliothèque ouvre à 9 h en semaine.</p>
</body>
</html>
The loading attribute tells the browser how to prioritize loading an image. Setting it to "lazy" defers loading until the image is near the viewport, which can improve page performance by reducing initial load time and saving bandwidth. Setting it to "eager" instructs the browser to load the image immediately, regardless of its position on the page. When the attribute is omitted, the browser defaults to "eager" behavior.
Any value other than these two exact lowercase strings is invalid according to the HTML specification. Common mistakes include using numeric values like "1" or "0", boolean-style values like "true" or "false", uppercase variants like "Lazy", or misspellings like "laxy". When a browser encounters an invalid value, it ignores the attribute and falls back to the default eager loading behavior. While this means the page won't break visually, the intended lazy-loading optimization won't take effect, and the HTML will fail W3C validation.
This matters for a few reasons:
- Performance: If you intended to use
"lazy"but provided an invalid value, your images will all load eagerly, defeating the purpose and potentially degrading page speed. - Standards compliance: Invalid attribute values signal potential bugs in your markup and can cause issues with tools and parsers that expect well-formed HTML.
- Maintainability: Valid, predictable markup is easier to maintain and debug across teams and over time.
To fix the issue, check the loading attribute value and replace it with one of the two valid options. If you want deferred loading, use "lazy". If you want immediate loading (or don't need to specify), use "eager" or simply remove the attribute.
Examples
Invalid values
Each of these will trigger the validation error:
<!-- Numeric value -->
<img src="photo.jpg" alt="A sunset over the ocean" loading="1">
<!-- Boolean-style value -->
<img src="photo.jpg" alt="A sunset over the ocean" loading="true">
<!-- Misspelled value -->
<img src="photo.jpg" alt="A sunset over the ocean" loading="laxy">
<!-- Wrong case -->
<img src="photo.jpg" alt="A sunset over the ocean" loading="Lazy">
Correct: lazy loading
Use "lazy" for images that are below the fold or not immediately visible to the user:
<img src="photo.jpg" alt="A sunset over the ocean" loading="lazy">
Correct: eager loading
Use "eager" for critical images that should load right away, such as hero images or logos:
<img src="logo.png" alt="Company logo" loading="eager">
Correct: omitting the attribute
Since "eager" is the default behavior, you can simply remove the attribute if you want immediate loading:
<img src="logo.png" alt="Company logo">
Practical usage in context
A common and effective pattern is to eagerly load above-the-fold images while lazy-loading everything else:
<!-- Hero image: load immediately -->
<img src="hero-banner.jpg" alt="Welcome to our store" loading="eager">
<!-- Product images further down the page: defer loading -->
<img src="product-1.jpg" alt="Running shoes" loading="lazy">
<img src="product-2.jpg" alt="Hiking boots" loading="lazy">
<img src="product-3.jpg" alt="Sandals" loading="lazy">
Note that the loading attribute also works on iframe elements with the same two valid values: "lazy" and "eager".
The media attribute tells the browser under which conditions a linked stylesheet (or other resource) should be applied. Its value must be a valid media query list as defined by the CSS Media Queries specification. When the W3C HTML Validator reports a parse error for this attribute, it means the value couldn't be parsed as a valid media query. The browser may ignore the attribute entirely or behave unpredictably, potentially loading the stylesheet in all conditions or not at all.
Common causes of this error include:
- Typos in media types or features — e.g.,
scrreninstead ofscreen, ormax-widhtinstead ofmax-width. - Missing parentheses around media features — e.g.,
max-width: 600pxinstead of(max-width: 600px). - Invalid or stray characters — e.g., extra commas, semicolons, or unmatched parentheses.
- Using CSS syntax instead of media query syntax — e.g., writing
@media screenor including curly braces. - Incorrect logical operators — e.g., using
orat the top level instead of a comma, or misspellingnotoronly. - Server-side template placeholders left unresolved — e.g.,
media="{{mediaQuery}}"rendered literally.
Getting this right matters for standards compliance and predictable cross-browser behavior. Browsers are generally lenient and may try to recover from malformed media queries, but the recovery behavior isn't guaranteed to be consistent. A broken media attribute can cause stylesheets to load when they shouldn't (wasting bandwidth) or not load when they should (breaking layout). It also affects performance, since browsers use the media attribute to prioritize resource loading.
To fix the issue, verify that your media value is a syntactically correct media query. Use valid media types (screen, print, all), wrap media features in parentheses, and separate multiple queries with commas.
Examples
Incorrect: missing parentheses around media feature
<!-- ❌ Parse error: media features must be wrapped in parentheses -->
<link rel="stylesheet" href="responsive.css" media="max-width: 600px">
Correct: parentheses around media feature
<link rel="stylesheet" href="responsive.css" media="(max-width: 600px)">
Incorrect: typo in media type
<!-- ❌ Parse error: "scrren" is not a valid media type -->
<link rel="stylesheet" href="styles.css" media="scrren">
Correct: valid media type
<link rel="stylesheet" href="styles.css" media="screen">
Incorrect: using or instead of a comma to separate queries
<!-- ❌ Parse error: top-level "or" is not valid between media queries -->
<link rel="stylesheet" href="styles.css" media="screen or print">
Correct: comma-separated media query list
<link rel="stylesheet" href="styles.css" media="screen, print">
Incorrect: stray semicolon in the value
<!-- ❌ Parse error: semicolons are not valid in media queries -->
<link rel="stylesheet" href="styles.css" media="screen; (max-width: 768px)">
Correct: combining media type and feature with and
<link rel="stylesheet" href="styles.css" media="screen and (max-width: 768px)">
More valid media query examples
<!-- Simple media type -->
<link rel="stylesheet" href="print.css" media="print">
<!-- Apply to all media (default behavior, but explicit) -->
<link rel="stylesheet" href="base.css" media="all">
<!-- Multiple conditions with "and" -->
<link rel="stylesheet" href="tablet.css" media="screen and (min-width: 768px) and (max-width: 1024px)">
<!-- Using "not" to exclude a media type -->
<link rel="stylesheet" href="no-print.css" media="not print">
<!-- Multiple queries separated by commas (logical OR) -->
<link rel="stylesheet" href="special.css" media="(max-width: 600px), (orientation: portrait)">
<!-- Prefers-color-scheme for dark mode -->
<link rel="stylesheet" href="dark.css" media="(prefers-color-scheme: dark)">
If you're unsure whether your media query is valid, try testing it in a browser's developer tools by adding a <style> block with @media and the same query — if the browser highlights it as invalid, the same value will fail in the media attribute.
The handheld media type is deprecated, and the validator rejects any media attribute on a <link> element that still lists it.
CSS 2.1 defined handheld for small-screen devices with limited bandwidth. Few browsers honored it. Safari on the iPhone ignored it and applied screen styles, and so did the smartphone browsers that came after. Media queries based on viewport width took over as the way to adapt a layout to small screens. Media Queries Level 4 deprecated handheld together with tty, tv, projection, braille, embossed and aural. Browsers still accept these types but never match them, so a stylesheet linked with media="handheld" is never applied.
The validator quotes the whole attribute value, and it reports the error even when handheld sits in a list next to a valid type, as in media="screen, handheld". In that case, delete handheld and keep the rest. If the stylesheet was meant for phones, replace handheld with a media query such as (max-width: 480px). If it should apply everywhere, remove the media attribute.
Modern browsers have been skipping any stylesheet marked handheld, so switching it to a media query makes its rules apply for the first time. Review those rules before you make the change.
Invalid example
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="mobile.css" media="handheld">
Valid example
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="mobile.css" media="(max-width: 480px)">
The media attribute on a <link> element specifies which media or device types the linked resource (typically a stylesheet) is designed for. It accepts a valid media query or a comma-separated list of media types. In the current CSS specification (Media Queries Level 4), only three media types remain valid: all, screen, and print. All other media types from older specifications — including projection, handheld, tv, tty, braille, embossed, and aural — have been deprecated.
The projection media type was originally intended to target presentation and projector-based displays. In practice, browser support for it was extremely limited (only Opera had meaningful support), and the use case never gained traction. The CSS Working Group deprecated it because the distinction between a "screen" and a "projection" display is no longer meaningful — modern browsers treat projectors, external displays, and monitors uniformly under the screen type.
Why this matters
- Standards compliance: Using deprecated media types causes W3C validation errors, which can signal broader code quality issues.
- No practical effect: Modern browsers simply ignore unrecognized media types. If
projectionis the only value in yourmediaattribute, the stylesheet may not load at all in some browsers. If it appears alongsidescreen, the browser loads the stylesheet based on thescreenmatch and silently discardsprojection— meaning the deprecated value adds nothing. - Maintainability: Keeping deprecated values in your code can confuse other developers and create the false impression that the stylesheet has special behavior for projectors.
How to fix it
- Remove
projectionfrom themediaattribute value. - If
screenor another valid type was already listed alongsideprojection, keep the valid type. - If
projectionwas the only value, replace it withscreen(since projectors are treated as screens by modern browsers). - If the stylesheet should apply universally, remove the
mediaattribute entirely or set it toall.
Examples
Incorrect
Using the deprecated projection media type alongside screen:
<link rel="stylesheet" href="style.css" media="screen, projection">
Using projection as the sole media type:
<link rel="stylesheet" href="slides.css" media="projection">
Correct
Remove projection and keep the valid screen type:
<link rel="stylesheet" href="style.css" media="screen">
Replace projection with screen, since projectors are handled as screens:
<link rel="stylesheet" href="slides.css" media="screen">
Target both screens and print:
<link rel="stylesheet" href="style.css" media="screen, print">
If the stylesheet should apply to all devices, omit the media attribute (which defaults to all):
<link rel="stylesheet" href="style.css">
Or explicitly set it to all:
<link rel="stylesheet" href="style.css" media="all">
Using media queries instead of media types
If you need more granular control over when a stylesheet applies — for example, targeting large displays commonly used for presentations — you can use a media query with feature conditions instead of relying on deprecated media types:
<link rel="stylesheet" href="presentation.css" media="screen and (min-width: 1920px)">
This approach is standards-compliant and gives you far more precise targeting than the old media types ever provided.
The media attribute on a <link> element specifies the conditions under which the linked resource should apply. It accepts either a simple media type or a full media query. When the validator reports "unrecognized media," it means the value you provided doesn't match any known media type or valid media query syntax.
Several older media types that were defined in earlier CSS specifications have been deprecated. Types like handheld, projection, tv, tty, aural, braille, and embossed are no longer recognized as valid. Modern CSS and HTML only support three media types: all, screen, and print. If you're using a deprecated type, you should replace it with an appropriate modern media query that targets the device characteristics you need.
Beyond deprecated types, this error also occurs when a media query expression is malformed — for example, missing parentheses around a feature expression, using an unknown feature name, or having a typo in the value.
Why this matters
- Standards compliance: Using unrecognized media types means your HTML doesn't conform to the current HTML and CSS specifications.
- Browser behavior: Browsers may ignore the entire
<link>element or apply the resource unconditionally when they encounter an unrecognized media type, leading to unexpected results. - Performance: The
mediaattribute helps browsers prioritize resource loading. A valid media query allows the browser to defer loading stylesheets that don't match the current context (e.g., print stylesheets), improving page load performance.
How to fix it
- Replace deprecated media types with
screen,print, orall, or use modern media queries that target specific device features. - Check for typos in your media type or query expression.
- Validate your media query syntax — feature expressions must be wrapped in parentheses and use recognized feature names like
max-width,orientation, orprefers-color-scheme.
Examples
Incorrect: using a deprecated media type
<link rel="stylesheet" href="mobile.css" media="handheld">
The handheld media type is deprecated and will trigger the validation error.
Incorrect: misspelled media type
<link rel="stylesheet" href="styles.css" media="screen">
Incorrect: malformed media query
<link rel="stylesheet" href="responsive.css" media="max-width: 768px">
The feature expression is missing its surrounding parentheses.
Correct: using valid media types
<link rel="stylesheet" href="general.css">
<link rel="stylesheet" href="print.css" media="print">
<link rel="stylesheet" href="screen.css" media="screen">
When no media attribute is specified, it defaults to all.
Correct: replacing deprecated types with modern media queries
Instead of media="handheld", use a media query that targets small screens or specific device capabilities:
<link rel="stylesheet" href="mobile.css" media="screen and (max-width: 768px)">
Correct: using complex media queries
<link rel="stylesheet" href="dark.css" media="(prefers-color-scheme: dark)">
<link rel="stylesheet" href="portrait.css" media="screen and (orientation: portrait)">
<link rel="stylesheet" href="large.css" media="screen and (min-width: 1200px)">
Valid media types reference
| Media type | Description |
|---|---|
all | Matches all devices (default when omitted) |
print | Matches printers and print preview mode |
screen | Matches screens (computers, tablets, phones) |
For anything more specific than these three types, use media feature expressions like (max-width: 600px), (hover: hover), or (prefers-reduced-motion: reduce) to target the exact device characteristics you need.
The method attribute on <form> accepts only get, post or dialog, so an empty value or an HTTP verb like PUT or DELETE is invalid.
The keywords are case-insensitive, so POST and post both work, but the value must match one of the three exactly. Extra whitespace, as in method=" post", also triggers this error. dialog only makes sense for a form inside a <dialog> element, where submitting closes the dialog instead of sending a request.
Browsers fall back to GET when the value is invalid. An empty method="" often comes from a template that prints an unset variable. The form still submits as GET, so remove the attribute or write method="get". An unsupported verb causes a real bug: a form with method="PUT" or method="DELETE" sends a GET request with the field values in the URL, so the server's PUT or DELETE handler never runs.
HTML forms can't send PUT, PATCH or DELETE requests. Use method="post" and tell the server which verb you meant. Frameworks such as Rails, Laravel and Phoenix read a hidden _method field for this, or you can send the request with fetch() from JavaScript.
Empty value
Invalid example
<form action="/search" method="">
<label for="q">Search</label>
<input id="q" name="q" type="search">
<button>Search</button>
</form>
Valid example
<form action="/search" method="get">
<label for="q">Search</label>
<input id="q" name="q" type="search">
<button>Search</button>
</form>
Unsupported HTTP verb
Invalid example
<form action="/profile" method="PUT">
<label for="name">Name</label>
<input id="name" name="name">
<button>Save</button>
</form>
Valid example
<form action="/profile" method="post">
<input type="hidden" name="_method" value="put">
<label for="name">Name</label>
<input id="name" name="name">
<button>Save</button>
</form>
The multiple attribute tells the browser that the user can supply more than one value for a given input. For <input type="file">, it allows selecting multiple files at once. For <input type="email">, it allows entering a comma-separated list of email addresses. These are the only two input types that support the multiple attribute according to the HTML specification.
This validation error can appear for two distinct reasons, and sometimes both at once:
An invalid value is assigned to the boolean attribute. Boolean attributes in HTML follow strict rules. Valid syntaxes are: the attribute name alone (
multiple), an empty string value (multiple=""), or the attribute's own name as the value (multiple="multiple"). Any other value — includingmultiple="true",multiple="1", ormultiple="yes"— is invalid.The attribute is used on an unsupported input type. Placing
multipleon input types liketext,number,password, orurlis not valid because those types don't define behavior for this attribute. Browsers will simply ignore it, but it still constitutes invalid markup.
Why this matters
- Standards compliance: Invalid boolean attribute values violate the WHATWG HTML specification. While most browsers are forgiving and may still interpret
multiple="true"as the attribute being present, relying on this behavior is fragile and non-standard. - Accessibility: Assistive technologies rely on valid, well-structured markup. An invalid attribute value could lead to unpredictable behavior in screen readers or other tools.
- Maintainability: Using
multipleon an unsupported input type suggests a misunderstanding of the element's capabilities, which can confuse other developers and lead to bugs.
How to fix it
- Remove the value entirely: Change
multiple="1"ormultiple="true"to justmultiple. - Use a valid boolean syntax if a value is required: Some templating systems or XML-based contexts (like XHTML) require explicit attribute values. In those cases, use
multiple=""ormultiple="multiple". - Ensure the input type supports
multiple: Onlytype="email"andtype="file"accept this attribute. If you need multi-value input for other types, consider alternative approaches like multiple separate inputs, a<select multiple>element, or a JavaScript-based solution.
Examples
Invalid: wrong value on a boolean attribute
<!-- Bad: "1" is not a valid boolean attribute value -->
<input type="file" name="attachments" multiple="1">
<!-- Bad: "true" is not a valid boolean attribute value -->
<input type="email" name="recipients" multiple="true">
Invalid: multiple on an unsupported input type
<!-- Bad: type="text" does not support the multiple attribute -->
<input type="text" name="tags" multiple>
<!-- Bad: type="number" does not support the multiple attribute -->
<input type="number" name="quantities" multiple>
Valid: correct usage of multiple
<!-- Correct: boolean attribute with no value -->
<input type="file" name="attachments" multiple>
<!-- Correct: empty string value (valid boolean syntax) -->
<input type="email" name="recipients" multiple="">
<!-- Correct: attribute name as value (valid for XHTML compatibility) -->
<input type="file" name="documents" multiple="multiple">
Full corrected document
<!DOCTYPE html>
<html lang="en">
<head>
<title>Upload Form</title>
</head>
<body>
<form action="/submit" method="post" enctype="multipart/form-data">
<label for="recipients">Recipients:</label>
<input type="email" id="recipients" name="recipients" multiple placeholder="a@example.com, b@example.com">
<label for="files">Attachments:</label>
<input type="file" id="files" name="files" multiple>
<button type="submit">Send</button>
</form>
</body>
</html>
In HTML, the name attribute on an <iframe> defines a browsing context name. This name can be referenced by other elements — for example, a link with target="my-frame" will open its URL inside the <iframe> whose name is "my-frame". The HTML specification reserves all browsing context names that start with an underscore for special keywords:
_self— the current browsing context_blank— a new browsing context_parent— the parent browsing context_top— the topmost browsing context
Because the underscore prefix is reserved for these (and potentially future) keywords, the spec requires that any custom browsing context name must not begin with _. Setting name="_example" or name="_myFrame" on an <iframe> is invalid HTML, even though those exact strings aren't currently defined keywords. Browsers may handle these inconsistently — some might ignore the name entirely, while others could treat it as one of the reserved keywords, leading to unexpected navigation behavior.
This matters for several reasons:
- Standards compliance: The WHATWG HTML living standard explicitly states that a valid browsing context name must not start with an underscore character.
- Predictable behavior: Using a reserved prefix can cause links or forms targeting that
<iframe>to navigate in unintended ways (e.g., opening in a new tab instead of within the frame). - Future-proofing: New underscore-prefixed keywords could be added to the spec, which might break pages that use custom names starting with
_.
To fix the issue, simply rename the name attribute value so it doesn't start with an underscore. You can use underscores elsewhere in the name — just not as the first character.
Examples
❌ Invalid: name starts with an underscore
<iframe src="https://example.com" name="_example"></iframe>
<a href="https://example.com/page" target="_example">Open in frame</a>
The name _example starts with an underscore, which makes it invalid. A browser might interpret _example unpredictably or ignore the name entirely when used as a target.
✅ Fixed: underscore removed from the start
<iframe src="https://example.com" name="example"></iframe>
<a href="https://example.com/page" target="example">Open in frame</a>
✅ Fixed: underscore used elsewhere in the name
<iframe src="https://example.com" name="my_example"></iframe>
<a href="https://example.com/page" target="my_example">Open in frame</a>
Underscores are perfectly fine as long as they aren't the first character.
❌ Invalid: using a reserved keyword as a frame name
<iframe src="https://example.com" name="_blank"></iframe>
Using _blank as an <iframe> name is also invalid because it's a reserved browsing context keyword. A link targeting _blank would open in a new window/tab rather than inside this <iframe>, which is almost certainly not what you intended.
✅ Fixed: descriptive name without underscore prefix
<iframe src="https://example.com" name="content-frame"></iframe>
<a href="https://example.com/page" target="content-frame">Open in frame</a>
How to fix
- Find every
<iframe>element whosenameattribute starts with_. - Rename each one by removing the leading underscore or replacing it with a letter or other valid character.
- Update any
targetattributes on<a>,<form>, or<base>elements that reference the old name so they match the new name. - Re-validate your HTML to confirm the issue is resolved.
Understanding Boolean Attributes in HTML
In HTML, boolean attributes work differently from regular attributes. A boolean attribute's presence on an element represents true, and its absence represents false. According to the HTML specification, a boolean attribute may only have three valid forms:
- The attribute name alone:
novalidate - The attribute with an empty value:
novalidate="" - The attribute with a value matching its own name (case-insensitive):
novalidate="novalidate"
Any other value — such as "true", "false", "1", "0", or "yes" — is invalid and triggers this validation error. This is a common source of confusion, especially for developers coming from frameworks like React (which uses noValidate={true}) or from languages where boolean attributes accept explicit true/false strings.
Why This Matters
- Standards compliance: Using invalid values violates the HTML specification and will cause W3C validation failures.
- Unexpected behavior: While most browsers are lenient and treat any value of
novalidateas "present" (meaning evennovalidate="false"would disable validation, not enable it), relying on this behavior is unreliable and misleading to other developers reading your code. - Maintainability: Writing
novalidate="false"suggests the form should be validated, but the opposite is true — the attribute is present, so validation is skipped. This creates confusing, error-prone code.
About the novalidate Attribute
The novalidate attribute tells the browser to skip its built-in constraint validation when the form is submitted. Without it, the browser checks required fields, input patterns, email formats, and other constraints before allowing submission.
If novalidate is not set on the form, individual submit buttons can still bypass validation on a per-button basis using the formnovalidate attribute on a <button>, <input type="submit">, or <input type="image"> element.
Examples
❌ Invalid: Arbitrary value on novalidate
<form method="post" novalidate="true">
<label>Email:
<input type="email" name="email" required>
</label>
<button>Submit</button>
</form>
This triggers the error because "true" is not a valid value for a boolean attribute. Other invalid variations include:
<form method="post" novalidate="1">
<form method="post" novalidate="yes">
<form method="post" novalidate="false">
Note that novalidate="false" is especially dangerous — it does not enable validation. Because the attribute is present, the browser disables validation regardless of the value.
✅ Valid: Attribute name alone (recommended)
<form method="post" novalidate>
<label>Email:
<input type="email" name="email" required>
</label>
<button>Submit</button>
</form>
✅ Valid: Empty string value
<form method="post" novalidate="">
<label>Email:
<input type="email" name="email" required>
</label>
<button>Submit</button>
</form>
✅ Valid: Value matching the attribute name
<form method="post" novalidate="novalidate">
<label>Email:
<input type="email" name="email" required>
</label>
<button>Submit</button>
</form>
✅ Valid: Removing the attribute to enable validation
If you want the form to be validated, simply remove the novalidate attribute entirely:
<form method="post">
<label>Email:
<input type="email" name="email" required>
</label>
<button>Submit</button>
</form>
✅ Using formnovalidate on a specific button
If you want validation on the primary submit but want to skip it for a "Save Draft" button, use formnovalidate on the button instead:
<form method="post">
<label>Email:
<input type="email" name="email" required>
</label>
<button>Submit</button>
<button formnovalidate>Save Draft</button>
</form>
This pattern keeps validation active for the main submission while allowing drafts to bypass it — without needing novalidate on the form at all.
The open attribute on <details> is a boolean attribute, so it doesn't take values like "true" or "false".
A boolean attribute is on when it's present and off when it's absent. HTML allows only two values for one: the empty string (open="") or the attribute's own name (open="open"). Anything else, such as "true", "false", "1" or "yes", is invalid, and the validator quotes the value it found in the message.
Browsers only check whether the attribute is there, so open="false" still renders the <details> element expanded. To start it collapsed, leave the attribute out.
This often happens when a template prints a boolean variable straight into the attribute, as in open="{{ is_open }}". Output the bare open attribute when the condition is true and nothing when it's false. In JavaScript, set the open property instead (details.open = false). It takes a real boolean and adds or removes the attribute for you.
Invalid example
<details open="true">
<summary>Shipping details</summary>
<p>Orders ship within two business days.</p>
</details>
<details open="false">
<summary>Return policy</summary>
<p>Returns are accepted within 30 days.</p>
</details>
Valid example
<details open>
<summary>Shipping details</summary>
<p>Orders ship within two business days.</p>
</details>
<details>
<summary>Return policy</summary>
<p>Returns are accepted within 30 days.</p>
</details>
The ping attribute specifies a space-separated list of URLs that the browser should notify (via a small POST request) when a user follows a hyperlink. This is commonly used for click tracking and analytics. According to the HTML specification, every URL in the list must be a valid, non-empty URL that uses either the http or https scheme — no other schemes or relative paths are permitted.
This restriction exists for practical and security reasons. The ping mechanism is specifically designed for web-based tracking endpoints, so only web protocols make sense. Relative URLs are disallowed because the ping is sent as a separate request independent of normal navigation, and the specification requires absolute URLs to unambiguously identify the target server. Using invalid values won't produce the intended tracking behavior and will cause the browser to silently ignore the ping attribute entirely.
From an accessibility and standards compliance standpoint, ensuring valid ping values means your analytics will work reliably in browsers that support the attribute. Note that browser support varies — some browsers (notably Firefox) disable ping by default or hide it behind a preference — so you should not rely on it as your sole tracking mechanism.
How to fix it
- Replace relative URLs with absolute URLs. If you have a value like
/trackortrack.php, prepend the full origin (e.g.,https://example.com/track). - Remove non-HTTP schemes. Values like
mailto:someone@example.comorftp://example.com/logare not valid forping. - Ensure each URL in the list is properly formatted. Multiple URLs must be separated by spaces (not commas or semicolons), and each one must be a complete
httporhttpsURL.
Examples
Incorrect: relative URL
<a href="https://example.com" ping="/track">Visit Example</a>
The value /track is a relative URL, which is not allowed in the ping attribute.
Incorrect: unsupported scheme
<a href="https://example.com" ping="ftp://example.com/log">Visit Example</a>
The ftp: scheme is not permitted — only http and https are valid.
Incorrect: comma-separated URLs
<a href="https://example.com" ping="https://example.com/track, https://analytics.example.com/log">Visit Example</a>
Multiple URLs must be space-separated, not comma-separated. The commas make each URL invalid.
Correct: single absolute URL
<a href="https://example.com" ping="https://example.com/track">Visit Example</a>
Correct: multiple space-separated absolute URLs
<a href="https://example.com" ping="https://example.com/track https://analytics.example.com/log">Visit Example</a>
Each URL is a fully qualified https URL, and they are separated by a single space. Both will receive a POST request when the link is clicked (in browsers that support the ping attribute).
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.
1K Weekly
1,000 monthly checks. Cancel anytime.
Get 1K Weekly →Join teams across 40+ countries