HTML Tutorial
HTML - Introduction HTML - Basic HTML - Structure HTML - Element HTML - Attributes HTML - Headings HTML - Paragraphs HTML - Styles HTML - Formatting HTML - Phrase Tags HTML - Quotations HTML - Comments HTML - Colors HTML - CSS HTML - Links HTML - Images HTML - Tables HTML - List HTML - Inline elements HTML - Block elements HTML - Classes HTML - Id HTML - Javascript HTML - File Path HTML - Iframe HTML - Responsive HTML - Computer Code HTML - Head tag HTML - Events HTML - Url Encoding HTML - Entities HTML - Validation
HTML Forms
HTML - Forms HTML - Form Elements HTML - Input types HTML - Input Attributes
HTML5
HTML5 - Introduction HTML5 - New Elements HTML5 - Semantics HTML5 - Style Guide
HTML Media
HTML - Video HTML - Audio HTML - Embed Multimedia
HTML Graphics
HTML - Canvas HTML - SVG
HTML APIs
HTML - Geolocation HTML - Drag & drop HTML - Web Storage HTML - Web Workers
HTML References
HTML - Tag Reference HTML - Tag by Category HTML - Attributes HTML - Global Attributes HTML - Events HTML - Language Codes HTML - Country Codes HTML - URL Encoding HTTP Methods HTTP Status Codes <input> types

Introduction to URL encoding

The URL is the address of a web page, like: https://parrot-tutorial.com/.

URL Encoding is the process of converting string, unprintable characters into valid URL format.

Any other characters that need to be added to a URL should be encoded so that they don't cause problems during the browser's trip to locate the pages and resources you are looking for.


URL encoding

URL encoding is normally performed to convert data passed via html forms, because such data may contain special character, such as <space>, &, $, <, >, ?, ;, # so on, which could either: a) have special meanings; or b) is not a valid character for an URL; or c) could be altered during transfer.

If you click the submit button and look at the resulting URL in the browser address bar, you should see something like this (the query string portion, which is automatically URL encoded by the browser, is shown in red):

https://parrot-tutorial.com/html/form-action.php?demo=Hello+%26+bye

Here, you can see that:

  • The <space> character has been URL encoded as "+"
  • The & character has been URL encoded as "%26"

Here's a table of some of often used characters and their URL encodings:

Character URL encoded
<space> %20  OR  +
! %21
" %22
# %23
$ %24
% %25
& %26
' %27
( %28
) %29
* %2A
+ %2B
, %2C
- %2D
. %2E
/ %2F
: %3A
; %3B
< %3C
= %3D
> %3E
? %3F
@ %40
[ %5B
\ %5C
] %5D
^ %5E
_ %5F
` %60
~ %7E

You will learn about HTML forms later in this tutorial.