# Bad value for attribute “href” on element “link”: Illegal character in scheme data: X is not allowed.

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

A `link` element's `href` attribute contains a character that is not valid in a URL, such as a space, curly brace, or other unencoded special character.

URLs in HTML must conform to the URL Living Standard. Certain characters are not allowed to appear literally in a URL and must be percent-encoded. Common offenders include spaces (use `%20`), curly braces `{` `}` (use `%7B` `%7D`), pipe `|` (use `%7C`), and angle brackets `<` `>` (use `%3C` `%3E`).

This error often appears when a template placeholder like `{{variable}}` is left unresolved in the `href` value, or when a URL is copied from another context and contains unencoded characters. The validator reads the raw HTML source, so even if a browser might handle a malformed URL gracefully, the markup is still invalid.

To fix it, replace every illegal character with its percent-encoded equivalent, or remove the character if it does not belong in the URL.

## Examples

### Invalid: unencoded characters in href

```html
<link rel="stylesheet" href="https://example.com/styles/main file.css">
```

The space between `main` and `file` is not allowed in a URL.

### Valid: percent-encoded URL

```html
<link rel="stylesheet" href="https://example.com/styles/main%20file.css">
```

If the illegal characters come from a template placeholder that was never processed, remove the placeholder or ensure it resolves before the HTML is served:

### Invalid: unresolved template syntax

```html
<link rel="icon" href="https://example.com/{{icon_path}}">
```

### Valid: resolved or corrected URL

```html
<link rel="icon" href="https://example.com/images/favicon.ico">
```
