What is a URL? The anatomy of a web address
Every web address is built from a few parts: scheme, domain, path, query and anchor. A plain breakdown of what each one does.
On this page
- The parts of a URL
- Scheme
- Authority: domain and port
- Path to the resource
- Query parameters
- Anchor (fragment)
- Absolute vs relative URLs
- Usernames and passwords in URLs
- Semantic URLs
- FAQ
- What are the five parts of a URL?
- Does the fragment (#anchor) get sent to the server?
- What is the difference between an absolute and a relative URL?
- Is putting a password in a URL still safe to use?
- Summary
A URL (Uniform Resource Locator) is the address of a unique resource on the internet — the string a browser uses to fetch a page, image or other file. This article breaks it into its parts and explains what each one does.
The parts of a URL
Take this address:
https://example.com:443/path/to/page?q=url#intro
It contains five parts, each with a job:
- Scheme —
https. Tells the browser which protocol to use to request the resource. - Authority —
example.com:443. Which server, and which "gate" (port) on that server. - Path —
/path/to/page. Which resource on that server. - Query —
?q=url. Extra key/value parameters for the server. - Anchor —
#intro. A bookmark inside the resource itself.
A handy way to remember them is the postal analogy: the scheme is the delivery service you choose, the domain is the city, the port is the zip code, the path is the building, the parameters are extra details like the apartment number, and the anchor is the specific person the mail is for.
Scheme
The first part of a URL indicates the protocol the browser must use. For websites this is almost always HTTPS (or its older, unsecured sibling HTTP). Browsers also handle other schemes: mailto: opens a mail client, and data: embeds small files directly in a document.
Authority: domain and port
The authority is separated from the scheme by ://. It contains the domain (for example example.com, or rarely a raw IP address) and an optional port, separated by a colon.
The port is the technical "gate" used to reach resources on the server. It is usually omitted because web servers use the standard ports — 80 for HTTP and 443 for HTTPS — but it becomes mandatory when a server listens on a non-standard port.
Not every scheme uses an authority. mailto:someone@example.com has a scheme but no // and no authority — the colon alone separates the scheme from the address.
Path to the resource
The path tells the server which resource you want. In the early days of the web, a path like /path/to/myfile.html pointed at a physical file on the server. Today it is mostly an abstraction: the server decides what to return for a given path, and the path may not correspond to any real file.
Query parameters
After the path, a ? starts the query string: a list of key/value pairs separated by &, like ?key1=value1&key2=value2. The server can use these parameters to change what it returns — for example a search term or a filter. Every server has its own rules for handling them.
Anchor (fragment)
The # starts the anchor — a "bookmark" inside the resource. On an HTML page the browser scrolls to that spot; on a video it jumps to a time. Importantly, the fragment is never sent to the server with the request: it exists only inside the browser.
Absolute vs relative URLs
The URLs above are absolute: they contain everything needed to locate a resource on their own. A URL typed into the address bar must be absolute (though you can omit the protocol, which defaults to HTTP, and the port when it is standard).
Inside a document, URLs can be relative: the browser fills in the missing parts using the current document's own URL. Examples of relative URLs:
//example.com/path— scheme-relative: uses the same protocol as the current page./path/to/page— domain-relative: same protocol and domain, path from the server root.page— a sub-resource relative to the current directory.../page— up one level in the directory tree.#anchor— anchor-only: a spot in the current document.
Usernames and passwords in URLs
You may occasionally see URLs like https://username:password@example.com/. This form was used with HTTP authentication to sign in automatically. It is deprecated for security reasons — modern sites use other login mechanisms — and you should not build URLs this way.
Semantic URLs
URLs are read by humans as well as computers. A semantic URL uses words with inherent meaning (/products/coffee-maker) instead of random-looking strings. They are easier to share and remember, clearer for users about where they are, and some search engines use their wording to help classify the page.
FAQ
What are the five parts of a URL?
A URL is built from a scheme (the protocol, like https), an authority (the domain and optional port), a path to the resource, optional query parameters, and an optional anchor (fragment). For example, in https://example.com:443/path/to/page?q=url#intro those five parts are https, example.com:443, /path/to/page, ?q=url and #intro.
Does the fragment (#anchor) get sent to the server?
No. The anchor is a bookmark inside the resource that exists only in the browser — on an HTML page it scrolls to a spot, on a video it jumps to a time. It is never sent to the server with the request.
What is the difference between an absolute and a relative URL?
An absolute URL contains everything needed to locate a resource on its own, which is why an address typed into the browser bar must be absolute. A relative URL fills in the missing parts using the current document's URL — for example //example.com/path reuses the page's protocol, and ../page goes one level up in the directory tree.
Is putting a password in a URL still safe to use?
No. The https://username:password@example.com/ form was used with HTTP authentication, but it is deprecated for security reasons. Modern sites use other login mechanisms, so you should not build URLs this way.
Summary
A URL is the address of a resource on the internet, built from a scheme, an authority (domain and port), a path, optional query parameters and an optional anchor. Absolute URLs work anywhere; relative URLs lean on the current page. The fragment never reaches the server, and the parts are few enough that anyone can learn to read them at a glance.
Sources
- MDN Web Docs — What is a URL? (developer.mozilla.org/en-US/docs/Learn_web_development/Howto/Web_mechanics/What_is_a_URL)
- MDN Web Docs — URL standard reference (developer.mozilla.org/en-US/docs/Web/URI/Reference/URL)
Share this guide
Related guides
- HTTP status codes explained: every code you'll actually see
What HTTP status codes mean, grouped by class — 1xx to 5xx — with the codes you'll meet in browsers, APIs, and server logs.
- What is the World Wide Web? How it's different from the internet
The web and the internet are not the same thing. A plain look at what each is, and how they fit together.
- HTTP request methods explained: GET, POST, PUT, DELETE & more
What HTTP request methods are, what each one does, and the difference between GET, POST, PUT, PATCH, DELETE and the rest — with safe vs idempotent.