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

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

A `mailto:` link follows URI syntax as defined by [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986), which does not permit raw space characters anywhere in the URI. When the W3C validator encounters a space inside the `href` value of a `mailto:` link, it reports it as an illegal character in the scheme data. This most commonly happens due to a typo in the email address itself — for example, accidentally inserting a space in the domain name (`example .com`) or the local part (`user name@example.com`). It can also occur when query parameters like `subject` or `body` contain unencoded spaces.

This matters for several reasons. First, browsers may truncate or misinterpret the `href` at the space boundary, meaning the mail client may open with an incorrect or incomplete email address. Second, assistive technologies rely on well-formed URIs to communicate link destinations to users. A malformed `mailto:` link can confuse screen readers or prevent users from understanding where the link leads. Third, invalid markup signals poor quality to search engines and automated tools.

To fix this issue:

1. **Check the email address for typos.** Remove any accidental spaces in the local part (before `@`) or the domain part (after `@`).
2. **Percent-encode spaces in query parameters.** If you're using `subject`, `body`, or `cc` parameters in the `mailto:` URI, replace spaces with `%20`.
3. **Avoid copying and pasting email addresses** from formatted documents, which can introduce non-breaking spaces or other invisible whitespace characters.

## Examples

### Invalid — space in the email address

A space in the domain name makes the URI invalid:

```html
<a href="mailto:user@example com">Send Email</a>
```

### Valid — corrected email address

Remove the space to form a valid email address:

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

### Invalid — space in the local part

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

### Valid — space removed from local part

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

### Invalid — unencoded spaces in subject parameter

```html
<a href="mailto:info@example.com?subject=Hello World">Email Us</a>
```

### Valid — percent-encoded spaces in subject parameter

Replace each space with `%20` in query parameter values:

```html
<a href="mailto:info@example.com?subject=Hello%20World">Email Us</a>
```

### Valid — full mailto with multiple parameters

```html
<a href="mailto:support@example.com?subject=Bug%20Report&body=Please%20describe%20the%20issue.">
  Report a Bug
</a>
```
