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

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

Spaces in the `href` attribute of a `<link>` element are not valid URL characters and must be encoded as `%20`.

URLs follow the syntax defined in [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986), which does not allow literal space characters in any component of a URI. The `<link>` element points to external resources such as stylesheets, icons, and preloaded files, and its `href` must be a valid URL. A browser often corrects the space on its own, but the markup is still invalid, so the validator flags it.

To fix the issue, replace each space in the URL with `%20`, the percent-encoded form of the space character. If the resource genuinely lives at a path that contains spaces, the encoding is still required for the reference to be valid.

This often appears with files whose names contain spaces, like an icon exported as `Capture 2026-06-23.webp`, or with folder names that include spaces.

## HTML examples

### Invalid: space in href

```html
<link rel="icon" href="https://example.com/files/Capture 2026-06-23.webp">
```

### Valid: spaces encoded as %20

```html
<link rel="icon" href="https://example.com/files/Capture%202026-06-23.webp">
```

If you control the file or directory names, renaming them to avoid spaces is a simpler long term fix. Use hyphens or underscores instead:

```html
<link rel="icon" href="https://example.com/files/capture-2026-06-23.webp">
```
