Within my HTML, can I use the character entity reference "
" in place of "%20
" in Web URLs?
They're both spaces, right?
Within my HTML, can I use the character entity reference "
" in place of "%20
" in Web URLs?
They're both spaces, right?
No. Neither are spaces (technically). Both represent spaces in different ways though. Make every effort to NOT have spaces, or representatives of spaces, in your URLs. Many find it more elegant (me included) to replace spaces with _ or -
No. is an HTML non-breaking-space entity; this entity has no meaning when used in a filesystem or wherever else that a URL might point. URLs are not encoded in HTML.
%20 is what you get with URL encoding, so this is what you should use if you are going to use it in a URL.
is a HTML entity, which is what should be used for 'non breaking space' in an HTML document.
No, not in the URLs. What you can do is replace spaces in the textual representation of the URL.
So instead of:
<a href="http://some.site/doc%20with%20spaces">http://some.site/doc%20with%20spaces</a>
you can have:
<a href="http://some.site/doc%20with%20spaces">http://some.site/doc&nbsp;with&nbsp;spaces</a>
Neither are spaces. You shouldnt be using spaces but if for what ever reason you can't avoid it you should just be able to do...
<a href="Web Page.aspx">Hey there</a>
...clicking on which will automatically navigate the user to
WebSite/Web%20Page.aspx
Most persons try to absolutely avoid spaces in their filenames in URLs. They will give you a serious headache every time so try to do so.
If you want to have spaces in an URL you have to encode them with %20.
  is used by the browser to know how to display the page. This information is only used for displaying. The %20 will be sent to the server that manages all the stuff needed to transfer the webpage to your visitors. The server doesn't speak html so the server would interpret   as a normal part of the filenname and search for a file called in the way foo bar. This file will not be found. Much worse the web server will think that the & begins the variable part of the url and only search for the page foo and then try to generate a variable nbsp and a variable bar but he want see any values for them. All in all the web server can't handle a URL with an in it.
The short answer is, they are both used to represent "spaces", but they represent different spaces.
%20
is the URL escaping for byte 32, which corresponds to plain old space in pretty much any encoding you're likely to use in a URL.
is an HTML character reference which actually refers to character 160 of Unicode (and also ISO-8859-1 aka Latin-1). It's a different space character entirely -- the "non-breaking space". Even though they look pretty much the same, they're different characters and it's unlikely that your server will treat them the same way.