Skip to content
Learn Netverks

Lesson

Step 37/58 64% through track

url-encode

URL encoding

Last reviewed May 28, 2026 Content v20260528
Track mode
iframe_html
Means
HTML preview sandbox
Reading
~1 min
Level
advanced

This lesson

This lesson teaches URL encoding—the ideas, syntax, and habits you need before moving on in HTML.

Without a solid grasp of URL encoding, you will repeat mistakes in HTML exercises and on real pages or scripts.

You will apply URL encoding in contexts like: Websites, hybrid apps, email templates, design systems, and CMS-driven content.

Read the lesson, edit HTML/CSS in the playground, press Run to preview, then answer the lesson MCQs. Also use the HTML reference desk when you need tag or attribute lookup.

When intermediate lessons feel comfortable and you are ready for production-style trade-offs.

URLs permit limited unescaped ASCII; everything else uses percent-encoding (%HH hex bytes). UTF-8 text becomes multiple percent escapes.

Forms

  • application/x-www-form-urlencoded spaces become + in payloads.
  • multipart/form-data handles binary uploads separately.

JavaScript helpers

  • encodeURIComponent for query parameter values.
  • encodeURI for entire URIs sparing reserved characters.

Server frameworks

Use standard libraries—manual concatenation risks injection bugs.

IRIs

Internationalized domain names apply Punycode in DNS; paths may include Unicode when properly encoded.

Double-encoding bugs

Frameworks sometimes encode once client-side and again server-side—watch for %2520 style sequences in logs.

Encode table (query strings)

CharacterMeaningEncoded
spacein forms often +%20 or +
&separator%26
=name=value%3D
?query start%3F
éUTF-8 bytes%C3%A9

Example — constructing a search URL

<!-- User typed: HTML & CSS ? -->
<a href="/search?q=HTML%20%26%20CSS%20%3F">Run search</a>

Rendered (link uses encoded query)

Sample encoded search link

In JavaScript prefer encodeURIComponent per parameter value—never hand-roll for untrusted text.

Important interview questions and answers

  1. Q: What is the safest default character encoding for modern HTML?
    A: UTF-8, declared early with `` and matched by server `Content-Type` headers.
  2. Q: When are HTML entities still useful in UTF-8 pages?
    A: For reserved characters (`&`, `<`) and contexts where explicit escaping avoids parser ambiguity.
  3. Q: What is the key difference between HTML5 parsing and XHTML parsing?
    A: HTML5 recovers from many errors; XHTML (XML) treats many parse errors as fatal.

Tip: Encode query values—spaces become %20 or + in forms.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • What confused you about this lesson?
  • How would you explain this to a teammate in 30 seconds?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump