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

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

A backslash (`\`) is not a valid character in a URL fragment and must be replaced with a forward slash (`/`) or percent-encoded.

The `href` attribute on an `<a>` element must contain a valid URL according to the [URL Living Standard](https://url.spec.whatwg.org/). The fragment portion of a URL — the part after the `#` symbol — follows the same rule: it can contain most characters, but the backslash (`\`) is explicitly forbidden as a bare character.

This commonly happens when copying file paths from Windows, which uses backslashes as directory separators, and pasting them into an `href`. Browsers may silently convert `\` to `/`, but the markup is still invalid.

To fix this, replace every `\` with `/` in the URL. If for some reason you actually need a literal backslash in the fragment, percent-encode it as `%5C`.

## HTML Examples

### ❌ Invalid: backslash in the fragment

```html
<a href="page.html#section\one">Link</a>
```

### ✅ Fixed: use a forward slash or percent-encoding

```html
<!-- Option 1: Replace with forward slash -->
<a href="page.html#section/one">Link</a>

<!-- Option 2: Percent-encode the backslash -->
<a href="page.html#section%5Cone">Link</a>
```
