Skip to main content

HTML Guide

Bad value X for attribute “src” on element “img”: Illegal character in path segment.

The src attribute on an element <img> contains a character which is not allowed unless properly encoded.

Special characters needing encoding are: :, /, ?, #, [, ], @, !, $, &, ', (, ), *, +, ,, ;, =, as well as % itself.

For example, this image tag is incorrect because the src attribute contains an the unallowed characters [ and ]:

<img src="image[00].svg" alt="logo">

Instead, this is the properly percent-encoded src attribute, where [ has been replaced with %5B and ] with %5D.

<img src="image%5B00%5D.svg" alt="logo">

Learn more:

Related W3C validator issues