# 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-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 is not allowed without percent-encoding it as `%7C`.

The fragment is the part of a URL that comes after the `#` symbol. According to [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986#section-3.5), fragments can only contain unreserved characters (`A-Z`, `a-z`, `0-9`, `-`, `.`, `_`, `~`), percent-encoded characters, sub-delimiters (`!`, `$`, `&`, `'`, `(`, `)`, `*`, `+`, `,`, `;`, `=`), `:`, `@`, `/`, and `?`.

The pipe character `|` is not in any of those sets, so it must be percent-encoded as `%7C` when used in a URL fragment.

This issue commonly appears when fragment identifiers are auto-generated from headings or content that contains `|`, such as table-related text or wiki-style page anchors.

## Invalid example

```html
<a href="/page#section|intro">Go to section</a>
```

## Valid example

Replace `|` with its percent-encoded equivalent `%7C`:

```html
<a href="/page#section%7Cintro">Go to section</a>
```

If you control the target element's `id`, a better approach is to remove the pipe character from the `id` altogether and use only unreserved characters:

```html
<h2 id="section-intro">Section intro</h2>
<a href="/page#section-intro">Go to section</a>
```
