# 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-replacement-character-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 contains `�` (U+FFFD, the Unicode replacement character), which the validator doesn't allow in a URL path.

A text decoder puts `�` in place of bytes that don't make a valid character in the encoding it's reading. In a URL, it marks where the original character, often a letter with an accent such as `é`, got lost. Browsers send it as `%EF%BF%BD`, so the link most likely leads to a page that doesn't exist.

Most of the time the page's encoding is to blame. With no `<meta charset>` in the document and no charset from the server, the validator falls back to `windows-1252` and reads UTF-8 bytes as the wrong characters. The reverse mismatch is a page that declares `utf-8` while the file is saved as `windows-1252`, where a byte such as `0xE9` (`é`) isn't valid UTF-8.

Either way, each byte that can't be decoded becomes `�`, and the report also shows "Malformed byte sequence" or "Unmappable byte sequence" errors. Leftover letters like `Ã` or `Â` next to the `�` in the reported value point the same way. Save the file as UTF-8 and declare it with `<meta charset="utf-8">` at the top of `<head>`, which also fixes any other garbled text on the page.

When the encoding is already right and the error doesn't go away, the `�` is in the source itself. The character was lost earlier, for example during an import into a CMS, and saved as `�`, so no encoding setting can bring it back. Write the intended character, percent-encode it (`é` is `%C3%A9`), or use an ASCII-only slug.

## Invalid example

```html
<a href="/menu/caf�-specials.html">Café specials</a>
```

## Valid example

Save the file as UTF-8, declare the encoding and write the intended character:

```html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Menu</title>
</head>
<body>
  <a href="/menu/café-specials.html">Café specials</a>
</body>
</html>
```

To keep the URL ASCII-only, percent-encode the character instead:

```html
<a href="/menu/caf%C3%A9-specials.html">Café specials</a>
```
