Inside a URL: Schemes, Hosts, Paths and Query Strings

By the ToolPocket team · Updated 2026-12-05 · Editorial standards

A URL is a small grammar with strict rules. Once you see its parts, most broken-link problems become obvious.

The parts

A URL looks like scheme://user:pass@host:port/path?query#fragment. The scheme says how to fetch it (https, mailto, data). The authority holds the host, optional port and rarely credentials. The path selects a resource. The query carries parameters. The fragment points inside the document.

What the server actually sees

Browsers do not send the fragment. If a page depends on #section to load data, the server never receives it; that has to happen in client-side JavaScript. Query parameters, by contrast, are sent and are visible in logs and caches.

Encoding rules

Characters outside the allowed set are percent-encoded as UTF-8 bytes: a space becomes %20, an ampersand in a value becomes %26. The tricky part is scope: encoding a whole URL must preserve its separators, while encoding a query value must escape them. That is why encodeURI and encodeURIComponent exist and are not interchangeable.

Common breakages

Relative and absolute URLs

A relative link such as ../tools/url-parser is resolved against a base URL. On a page at /guides/inside-a-url, that becomes /tools/url-parser. The same HTML deployed under a subdirectory resolves differently, which is why static sites prefer root-relative paths (/tools/...) when the site lives at the domain root.

That distinction causes a lot of invisible breakage: pages that work locally and fail in production, or links that silently point at the wrong section after a site move. The base URL is part of the address, not a detail.

Inspect instead of guessing

Paste a link into the URL parser to see each component decoded and every query parameter listed in order. The URL encoder handles the encoding step correctly.

← All guides