HTML URL Encoding

URL encoding converts special characters into a format that can be safely used in URLs.


Why URL Encoding Is Needed

URLs cannot contain spaces or special characters.

Example:

hello world

Encoded as:

hello%20world

URL Encoding Example

<a href="search.html?query=html%20tutorial">
  Search HTML Tutorial
</a>

Common Encoded Characters

  • Space → %20
  • !%21
  • @%40
  • #%23

Important Notes

  • Encoding ensures valid URLs
  • Browsers encode URLs automatically
  • Useful for query strings