-
Hajipur, Bihar, 844101
Hajipur, Bihar, 844101
HTML5 Basics
HTML Introduction
HTML Editors
HTML Basic
HTML Elements
HTML Attributes
HTML Headings
HTML Paragraphs
HTML Styles
HTML Formatting
HTML Quotations
HTML Comments
HTML Styling and Design
HTML Links and Media
HTML Layout and Structure
HTML Tables
HTML Lists
HTML Block & Inline
HTML Div
HTML Classes
HTML Id
HTML Head
HTML Layout
HTML Responsive
HTML Computercode
HTML Semantics
HTML Forms
HTML Forms
HTML Form Attributes
HTML Form Elements
HTML Input Types
HTML Input Attributes
Input Form Attributes
HTML Graphics
HTML APIs
HTML Advanced Topics
URL Encoding is the process of converting characters into a format that can be transmitted over the Internet. URLs can only be sent over the Internet using the ASCII character set, so URL encoding converts non-ASCII or unsafe characters into a format using %
followed by two hexadecimal digits.
URLs cannot contain spaces or certain special characters.
Encoding converts reserved characters into a valid format.
Ensures URLs are transmitted correctly and safely.
Space (
) → %20
or +
<
→ %3C
>
→ %3E
#
→ %23
%
→ %25
{
→ %7B
}
→ %7D
|
→ %7C
\
→ %5C
^
→ %5E
~
→ %7E
[
→ %5B
]
→ %5D
`
→ %60
Original URL with unsafe characters:
https://example.com/search?query=HTML URL Encode & test
URL Encoded:
https://example.com/search?query=HTML%20URL%20Encode%20%26%20test
const originalUrl = "https://example.com/search?query=HTML URL Encode & test";
const encodedUrl = encodeURIComponent("HTML URL Encode & test");
console.log(encodedUrl);
// Output: HTML%20URL%20Encode%20%26%20test
const fullUrl = `https://example.com/search?query=${encodedUrl}`;
console.log(fullUrl);
// Output: https://example.com/search?query=HTML%20URL%20Encode%20%26%20test
HTML forms automatically encode form data when using GET
or POST
method.
Example:
<form action="/search" method="get">
<input type="text" name="query" />
<input type="submit" value="Search" />
</form>
If user enters HTML URL Encode & test
, the browser encodes it before sending.
Q1. Explain why spaces are encoded in URLs.
Q2. Encode the URL parameter name=John Doe & Sons
.
Q3. Decode the encoded URL string %3Cdiv%3EHello%3C%2Fdiv%3E
.
Q4. Write JavaScript to encode a query string for a URL.
Q5. Create an HTML form that sends URL-encoded data using GET method.
Q6. Show examples of reserved characters in URLs that must be encoded.
Q7. Explain difference between encodeURI
and encodeURIComponent
in JavaScript.
Q8. Describe how browsers handle URL encoding in form submission.
Q9. Write a PHP snippet to decode URL encoded strings.
Q10. List characters that do NOT need encoding in URLs.
HTML5 Basics
HTML Introduction
HTML Editors
HTML Basic
HTML Elements
HTML Attributes
HTML Headings
HTML Paragraphs
HTML Styles
HTML Formatting
HTML Quotations
HTML Comments
HTML Styling and Design
HTML Links and Media
HTML Layout and Structure
HTML Tables
HTML Lists
HTML Block & Inline
HTML Div
HTML Classes
HTML Id
HTML Head
HTML Layout
HTML Responsive
HTML Computercode
HTML Semantics
HTML Forms
HTML Forms
HTML Form Attributes
HTML Form Elements
HTML Input Types
HTML Input Attributes
Input Form Attributes
HTML Graphics
HTML APIs
HTML Advanced Topics