Skip to main content
HTML Validation

Bad value X for attribute “src” on element “script”: Illegal character in path segment: space is not allowed.

About This HTML Issue

The issue arises from the space character in the src attribute value of the script element. In URLs, spaces are not allowed and should be properly encoded to avoid validation errors.

Fix

Replace spaces with %20, which is the URL-encoded representation of a space.

Example

Before:

<script src="https://example.com/media assets/app.js"></script>

After:

<script src="https://example.com/media%20assets/app.js"></script>

Explanation

In this example, the space between “media” and “assets” in the URL is replaced with %20. This change ensures that the URL conforms to standards and is correctly processed by browsers and servers. Spaces and other special characters in URLs must be encoded to ensure proper formatting and accessibility.

Learn more:

Last reviewed: March 31, 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.