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

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

A `|` (pipe) character in the fragment portion of a URL must be percent-encoded as `%7C` to be valid.

The `href` attribute on an `<a>` element must contain a valid URL. According to the URL specification, certain characters — including the pipe `|` — are not permitted as literal characters in a URL fragment (the part after `#`). The W3C validator flags this because the browser may handle it inconsistently, and it violates the URL standard.

To fix it, replace every `|` in the URL with its percent-encoded equivalent: `%7C`.

## HTML Examples

### ❌ Invalid: literal pipe in fragment

```html
<a href="https://example.com/page#section|one">Link</a>
```

### ✅ Valid: percent-encoded pipe in fragment

```html
<a href="https://example.com/page#section%7Cone">Link</a>
```

If you control the target page, consider redesigning the fragment identifiers to avoid special characters altogether — for example, using hyphens or underscores like `#section-one` instead.
