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

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

Spaces in the `src` attribute of a `<source>` element are not valid URL characters and must be encoded or removed.

URLs follow strict syntax rules defined in [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986). A space character is not permitted in any part of a URL path. When a file name or path contains spaces, you must replace each space with `%20` (the percent-encoded form) or rename the file to avoid spaces altogether.

This applies to all elements that accept a URL, including `<source>`, `<img>`, `<a>`, `<script>`, and `<link>`. Browsers often handle spaces gracefully by encoding them automatically, but the HTML is still technically invalid and can cause issues in some contexts, such as when URLs are copied, shared, or processed by other tools.

The best practice is to avoid spaces in file names entirely. Use hyphens (`-`) or underscores (`_`) instead. If you can't rename the files, percent-encode the spaces.

## Bad Example

```html
<video controls>
  <source src="videos/my cool video.mp4" type="video/mp4">
</video>
```

## Good Example — Percent-Encoded Spaces

```html
<video controls>
  <source src="videos/my%20cool%20video.mp4" type="video/mp4">
</video>
```

## Good Example — No Spaces in File Name

```html
<video controls>
  <source src="videos/my-cool-video.mp4" type="video/mp4">
</video>
```
