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

> Canonical HTML version: https://rocketvalidator.com/html-validation/bad-value-x-for-attribute-href-on-element-a-illegal-character-in-path-segment-caret-is-not-allowed
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

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

```html
<a href="/files/meeting-minutes-^2.pdf">Meeting minutes (PDF)</a>
```

## Valid example

Rename the file so its name has no caret:

```html
<a href="/files/meeting-minutes-2.pdf">Meeting minutes (PDF)</a>
```

If the file name can't change, percent-encode the caret:

```html
<a href="/files/meeting-minutes-%5E2.pdf">Meeting minutes (PDF)</a>
```
