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

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

A `data:` URI in the `href` attribute of a `<link>` element can't contain literal spaces, so an inline SVG icon in that URI needs every space written as `%20`.

The `data:` scheme, defined in [RFC 2397](https://www.rfc-editor.org/rfc/rfc2397), puts the file itself in the attribute value. The data after the comma may only contain URL characters, and a space isn't one of them. The `ta:` in the message is the end of `data:`: the validator quotes the scheme, not the position of the space, so the space can be anywhere in the value. When the value runs past about a thousand characters, the validator leaves it out of the message, which then reads `Bad value  for attribute “href”` with nothing between the two words.

The usual cause is a favicon written as inline SVG, as in `<link rel="icon" href="data:image/svg+xml,...">`. SVG markup needs a space between the element name and each attribute, and encoding only the angle brackets as `%3C` and `%3E` leaves those spaces in place. Spaces inside attribute values, such as `viewBox='0 0 16 16'` or the numbers in a path's `d` attribute, trigger it too.

Browsers usually show the icon anyway, but the value is still an invalid URL. Replace every space with `%20`, or base64-encode the SVG and add `;base64` before the comma. In JavaScript, `encodeURIComponent()` converts the spaces along with the other reserved characters. If the icon is large or used on many pages, save it as a `.svg` file and point `href` at that file, which also lets the browser cache it.

## Invalid example

```html
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='8' fill='teal'/%3E%3C/svg%3E">
```

## Valid example

```html
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
```
