browser and url: space in file names

It looks like today's browsers will automatically convert spaces in url to the required precent encoding %20 in your html links or image links. For example, suppose you have this image at 〔http://example.com/i/my house.jpg〕. Notice the space there. In your html code, you can just do this:

<img src="http://example.com/i/my house.jpg" alt="my house">

It works in all current version of browsers. It appears that the browsers will encode it for you before sending the HTTP request. e.g. browsers will send GET /i/my%20house.jpg HTTP/1.1.

Of course, by spec, you should encode spaces by %20 in your URI. The common practice today is still not to use any spaces in file names on server. Because this encoding creates a lot complexities. Though, i'm not sure how long this practice will last, because space is just so much easier to type, easier to read, and frequently needed. I wonder, if in a few years, maybe common web practice will use spaces in file names and leave space as is in all url in html.

For some tech discussion, see: Source stackoverflow.com.

See also: What Characters Are Not Allowed in File Names?URL Percent Encoding and UnicodeURL Percent Encoding and Ampersand Char.

Popular posts from this blog

11 Years of Writing About Emacs

does md5 creates more randomness?

Google Code shutting down, future of ErgoEmacs