HTML URLs and URL Encoding
URL—Uniform Resource Locator
A URL is used to address a document (or other data) on the World Wide Web.
A web address follows these syntax rules:
scheme://host.domain:port/path/filename
scheme: defines the type of Internet service, e.g., http, ftp, and mailto.
host: defines the domain host
(the default host for http is www).
domain: defines the Internet domain name, like w3schools.com.
:port: defines the port number at the host, e.g., 80, the default number.
path: defines a path at the server.
filename: defines the name of a document/resource.
URL Encoding
URL encoding converts characters into a format that can be transmitted over the Internet.
URLs can only be sent over the Internet using the ASCII character-set.
Since URLs often contain characters outside the ASCII set, the URL has to be converted into a valid ASCII format.
URL encoding replaces non ASCII characters with a ‘%’ followed by two hexadecimal digits.
For example, URLs cannot contain spaces.
URL encoding normally replaces a space with a + sign.
If you click the “Submit” button above, the browser will URL encode the input before it is sent to the server.
A page at the server will display the received input.
Some of the URL-encodings are listed as follows:
| Character |
URL-Encoding |
|
Character |
URL-Encoding |
|
Character |
URL-Encoding |
| @ |
%40 |
# |
%23 |
$ |
%24 |
| % |
%25 |
& |
%26 |
' |
%27 |
| < |
%3C |
= |
%3D |
? |
%3F |
Demonstration
The following demonstration shows how the HTML script is displayed on the Web:
Today at the bank,
an old lady asked me to help check her balance.
So I pushed her over.
|