HTML Guides for caret
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.
The href value on the <a> element has a literal ^ (caret) in its path, and a URL can only carry that character percent-encoded as %5E.
The URL standard doesn't list ^ among the characters a URL can contain. Browsers still follow the link, but the markup is invalid.
The caret usually comes from a file name. A document saved as meeting-minutes-^2.pdf and uploaded to a CMS keeps the caret in its address, and every link to it repeats it. Rename the file without the caret and update the links, adding a redirect from the old address if other sites link to it. If the file has to keep its name, write the caret as %5E in the href. The server decodes %5E back to ^ when it looks up the file, so the encoded link still opens the same document.
A caret in the query string or the fragment gets a different message, ending in "Illegal character in query" or "Illegal character in fragment". When the href is very long, the validator leaves the value out of the message. The cause and the fix are the same.
Invalid example
<a href="/files/meeting-minutes-^2.pdf">Meeting minutes (PDF)</a>
Valid example
Rename the file so its name has no caret:
<a href="/files/meeting-minutes-2.pdf">Meeting minutes (PDF)</a>
If the file name can't change, percent-encode the caret:
<a href="/files/meeting-minutes-%5E2.pdf">Meeting minutes (PDF)</a>
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