Skip to main content
HTML Validation

Bad value X for attribute “href” on element “a”: Illegal character in path segment. “^” is not allowed.

About This HTML Issue

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>

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Help us improve our guides

Was this guide helpful?
🌍 Trusted by teams worldwide

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.

Scheduled Reports
API Access
Open Source Standards
€5 / week

1K Weekly

1,000 monthly checks. Cancel anytime.

Get 1K Weekly →

Join teams across 40+ countries