Moon Moon - 3 months ago 30
HTML Question

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

it has always been my practice that when ever i use images i name them like


so when i give paths they go like

<img src="images/walls_ico.ico" />
<img src="buttons/bu_hover.png" />

UNTIL now when i am on a project where users upload files...

i was wondering is it okay to have spaces between file and folders name like

<img src="buttons/bu hover.png" />

Answer Source

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="buttons/bu%20hover.png" />

But not:

<img src="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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download