# Bad value “tel: X” for attribute “href” on element “a”: Illegal character in scheme data.

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

A URI (Uniform Resource Identifier) follows a strict syntax defined by [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986). The general structure is `scheme:scheme-data`, where no spaces or other illegal characters are allowed between the colon and the scheme-specific data. When the W3C validator reports "Illegal character in scheme data," it means the parser found a character that isn't permitted in that position of the URI.

The most common cause of this error is adding a space after the colon in `tel:` links (e.g., `tel: +123456789`). While browsers may be forgiving and still handle the link, the markup is technically invalid. This matters for several reasons:

- **Accessibility:** Screen readers and assistive technologies rely on well-formed URIs to correctly identify link types. A malformed `tel:` link might not be announced as a phone number.
- **Standards compliance:** Invalid URIs violate the HTML specification, which requires the `href` attribute to contain a [valid URL](https://url.spec.whatwg.org/).
- **Cross-device behavior:** Mobile devices use the URI scheme to determine which app should handle a link. A malformed `tel:` URI may fail to trigger the phone dialer on some devices or operating systems.
- **Interoperability:** While some browsers silently trim spaces, others may encode them as `%20`, potentially breaking the phone number or other scheme data.

To fix this issue, ensure there are no spaces or other illegal characters between the scheme's colon and the data that follows it. For telephone links specifically, the number should follow the colon directly, using only digits, hyphens, dots, parentheses, and the `+` prefix as defined by [RFC 3966](https://www.rfc-editor.org/rfc/rfc3966).

## Examples

### Incorrect: space after the colon in a `tel:` link

```html
<a href="tel: +1-234-567-8900">Call us</a>
```

The space between `tel:` and `+1` is an illegal character in the URI scheme data.

### Correct: no space after the colon

```html
<a href="tel:+1-234-567-8900">Call us</a>
```

### Incorrect: space after the colon in a `mailto:` link

```html
<a href="mailto: support@example.com">Email support</a>
```

### Correct: `mailto:` with no space

```html
<a href="mailto:support@example.com">Email support</a>
```

### Incorrect: other illegal characters in scheme data

```html
<a href="tel:+1 234 567 8900">Call us</a>
```

Spaces within the phone number itself are also illegal characters in the URI. Use hyphens, dots, or no separators instead.

### Correct: valid separators in a phone number

```html
<a href="tel:+1-234-567-8900">Call us</a>
<a href="tel:+1.234.567.8900">Call us</a>
<a href="tel:+12345678900">Call us</a>
```

### Visual formatting vs. the `href` value

If you want the displayed phone number to include spaces for readability, format the visible text separately from the `href` value:

```html
<a href="tel:+12345678900">+1 234 567 8900</a>
```

The `href` contains a valid URI with no spaces, while the link text is formatted for easy reading. This gives you the best of both worlds — valid markup and a user-friendly display.
