Spaces are not an allowed character within a URI. Since many symbols (such as a space, which is an invisible symbol) are not allowed in a URI, then a technique called "escaped octet" was introduced to allow you to pass ASCII symbols (such as a space, among many others) in the URI without breaking the URI.
The percentage sign (%) followed by the two hexadecimal digits representing the octet code correspond to ASCII symbols. This is the official way to pass a non-allowed symbol into a URI string.
Now let's say you want to add a space to your URI for some reason (this really shouldn't be necessary, but let's run with it). Since a space is not allowed in the URI, we instead would _represent_ a space with "%20" which is the escaped octet that corresponds with a space. Browsers and server side languages would then translate this effectively to a space character.
Old browsers would break if you attempted to add spaces or other non-allowed symbols to a URL in the address bar. This required you to manually encode these symbols yourself, such as in his first example where he writes:
These queries would get passed to the server as `q: "hello world"` and `another: "query parameter"`.
However in more modern browsers, we have attempted to make it easier for people to understand and write URLs. So browsers now correct errors made in your URI syntax for you by looking for those non-allowed characters and encoding them for you automatically before they actually submit the request.
will succeed in modern browsers thanks to the fact that the browser is secretly encoding this for you.
Most people, even a surprising amount of web developers, have grown up in a time when they never had to fully understand the fundamentals of URI structure and uniform standards because browsers have protected them from making mistakes. This is similar to how many new developers don't understand memory management in apps, because many tools have handled this for them in recent years.
The main point I was making here was also that there's actually TWO DIFFERENT ESCAPING MECHANISMS at work here. percent encoding AND html entity encoding. If this was a javascript property assignment, I might even need to add in backslash encoding. You're supposed to entity encode the ampersand in a query string as &. If you don't, some text editors will even highlight it as a syntax error for you.
the fact that ampersand was chosen as a query term seperator for URLs, knowing that they're also a special character in html that introduce entitity encodings, seems like it was a bit shortsighted. Browsers won't complain about an unencoded ampersand in a URL, but the the html validators will.
Historically, semicolon ; is also supposed to work as a query term seperator, (in particular, for map coordinates!), and you wouldn't need to entity encode it. but this is such an obscure and historical factoid that it is not consistently implemented, and you can only use it if you know everything handling that url will definitely cope with it correctly.
fun factoid: I once broke Ruby On Rails by convincing DHH using semicolons in query strings was a good idea. Apparently some older versions of safari, and certain proxies broke down when encountering them.
[RFC #2396](https://tools.ietf.org/html/rfc2396) defines an official standard for URIs.
Spaces are not an allowed character within a URI. Since many symbols (such as a space, which is an invisible symbol) are not allowed in a URI, then a technique called "escaped octet" was introduced to allow you to pass ASCII symbols (such as a space, among many others) in the URI without breaking the URI.
The percentage sign (%) followed by the two hexadecimal digits representing the octet code correspond to ASCII symbols. This is the official way to pass a non-allowed symbol into a URI string.
Now let's say you want to add a space to your URI for some reason (this really shouldn't be necessary, but let's run with it). Since a space is not allowed in the URI, we instead would _represent_ a space with "%20" which is the escaped octet that corresponds with a space. Browsers and server side languages would then translate this effectively to a space character.
Old browsers would break if you attempted to add spaces or other non-allowed symbols to a URL in the address bar. This required you to manually encode these symbols yourself, such as in his first example where he writes:
These queries would get passed to the server as `q: "hello world"` and `another: "query parameter"`.However in more modern browsers, we have attempted to make it easier for people to understand and write URLs. So browsers now correct errors made in your URI syntax for you by looking for those non-allowed characters and encoding them for you automatically before they actually submit the request.
So now typing:
will succeed in modern browsers thanks to the fact that the browser is secretly encoding this for you.Most people, even a surprising amount of web developers, have grown up in a time when they never had to fully understand the fundamentals of URI structure and uniform standards because browsers have protected them from making mistakes. This is similar to how many new developers don't understand memory management in apps, because many tools have handled this for them in recent years.