Skip to main content

HTML Guide

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

A space in the href URL wasn’t percent-encoded, making the link invalid.

The href attribute must contain a valid URL. Spaces and certain characters are not allowed in URLs and must be percent-encoded. In paths and query strings, replace spaces with %20 (or use + only in application/x-www-form-urlencoded query values, not paths).

Prefer generating properly encoded URLs server-side or via encodeURI/encodeURIComponent in JS. For fragment-only links, use href="#id". Avoid unencoded spaces anywhere after the scheme (e.g., https: or mailto:).

HTML Examples

Invalid (reproduces the validator error)

<a href="https://example.com/files/My File.pdf">Download</a>

Fixed (spaces percent-encoded)

<a href="https://example.com/files/My%20File.pdf">Download</a>

Learn more:

Related W3C validator issues