# Bad value for attribute “href” on element “link”: Illegal character in query: space is not allowed.

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

A space character in the `href` attribute of a `<link>` element is not valid in a URL and must be encoded as `%20`.

URLs follow strict syntax rules defined in [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986). Spaces are not permitted anywhere in a URL, including the query string (the part after the `?`). When a URL needs to represent a space, it must be percent-encoded as `%20`.

Browsers are forgiving and will often handle spaces by silently encoding them, but the HTML is still technically invalid. This can lead to unexpected behavior in less forgiving environments like HTML emails, web crawlers, or certain HTTP clients.

## Invalid Example

```html
<link rel="stylesheet" href="https://example.com/styles?family=Open Sans">
```

## Fixed Example

Replace every space with `%20`:

```html
<link rel="stylesheet" href="https://example.com/styles?family=Open%20Sans">
```

If your URL has multiple spaces or special characters, make sure each one is properly percent-encoded. Common replacements include `%20` for spaces, `%26` for `&` inside already-encoded contexts, and `%3D` for `=`. Most programming languages offer a URL-encoding function (e.g., `encodeURI()` in JavaScript) to handle this automatically.
