href syntax : is it okay to have space in file name

The src attribute should contain a valid URL. Since space characters are not allowed in URLs, you have to encode them.

You can write:

<img src="https://stackoverflow.com/questions/4172579/buttons/bu%20hover.png" />

But not:

<img src="https://stackoverflow.com/questions/4172579/buttons/bu+hover.png" />

Because, as DavidRR rightfully points out in his comment, encoding space characters as + is only valid in the query string portion of an URL, not in the path itself.

Leave a Comment