Skip to main content
HTML Validation

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

About This HTML Issue

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>

Last reviewed: August 13, 2025

Was this guide helpful?

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Ready to validate your sites?
Start your free trial today.