A URL (Uniform Resource Locator) is a standardized text string that identifies a resource and specifies how to retrieve it: which protocol to use, which host to contact, and which path, query and fragment select the exact item. A URL such as https://shop.example.com:443/catalog/chairs?color=oak#reviews combines all of these parts in a fixed syntax.
Among internet protocols, the URL is the addressing layer used by HTTP, HTTPS, FTP and many other schemes. Its generic syntax is defined in RFC 3986 as a form of URI, while browsers follow the WHATWG URL Standard, which describes how real-world, sometimes malformed addresses are parsed in practice.
Anatomy of a URL
A URL is built from up to seven components, separated by reserved characters. Only the scheme and, for most schemes, the host are mandatory; the remaining parts refine the request.
| Component | Example | Purpose |
|---|---|---|
| Scheme | https | Protocol used to access the resource |
| Userinfo | user@ | Optional credentials, now discouraged |
| Host | shop.example.com | Domain name or IP address of the server |
| Port | :443 | Network port, omitted when it is the scheme default |
| Path | /catalog/chairs | Location of the resource on the server |
| Query | ?color=oak | Parameters, usually key and value pairs |
| Fragment | #reviews | Part within the resource, handled by the client |
The scheme, userinfo, host and port together form the authority and origin of the URL. The fragment is never sent to the server; the browser uses it locally to scroll to an element or to pass state to a script. Scheme and host are case-insensitive, while the path and query are usually case-sensitive.
How a browser resolves and uses a URL
When a user enters a URL or follows a link, the browser first parses the string into its components and normalizes it, for example by lowercasing the host and removing a default port. It then turns the host into an IP address through DNS resolution, opens a connection to the given port, negotiates TLS for HTTPS and sends an HTTP request whose target is the path and query.
Links inside a page often use relative URLs such as ../images/logo.png or /about. The browser resolves them against the base URL of the current document. A URL beginning with two slashes, for example //cdn.example.com/app.js, is scheme-relative and inherits the scheme of the page.
The origin derived from a URL, the combination of scheme, host and port, is the basis of the browser’s same-origin policy. Two URLs that differ only in their port are therefore treated as different origins with separate cookies, storage and permissions.
Common URL schemes
The scheme determines which protocol and rules apply to the rest of the URL. Default ports allow most URLs to omit the port number entirely.
| Scheme | Protocol or purpose | Default port |
|---|---|---|
| http | Hypertext Transfer Protocol, unencrypted | 80 |
| https | HTTP over TLS | 443 |
| ftp | File Transfer Protocol | 21 |
| ws and wss | WebSocket and secure WebSocket | 80 and 443 |
| mailto | Address an email message | Not applicable |
| file | Local file system resource | Not applicable |
| data | Inline content embedded in the URL | Not applicable |
Schemes such as mailto and data have no host or network location, which shows that a URL does not always point to a server; it always tells software how to obtain the resource.
URL compared with URI and URN
The terms URL, URI and URN are related but not identical. A URI (Uniform Resource Identifier) is the general category of identifiers. A URL is a URI that also provides a means of locating the resource, while a URN (Uniform Resource Name) names a resource persistently without saying where it is.
| Identifier | What it provides | Example |
|---|---|---|
| URI | Any identifier following the generic syntax | https://example.com/ or urn:isbn:0451450523 |
| URL | Identity plus access method and location | https://example.com/docs/guide |
| URN | Persistent, location-independent name | urn:isbn:0451450523 |
In current web standards, the distinction has blurred, and the WHATWG specification simply uses URL for all web addresses. In formal protocol documents, however, URI remains the technically precise term.
Encoding, length and internationalization
URLs may contain only a limited set of ASCII characters. Any other byte, including spaces and reserved characters used as data, is written with percent-encoding: a percent sign followed by two hexadecimal digits, so a space becomes %20 and an ampersand inside a value becomes %26. Non-ASCII text is first converted to UTF-8, then percent-encoded.
Internationalized domain names are handled differently. The host is converted to an ASCII form called Punycode, so a name with accented letters appears on the wire with the xn-- prefix. Browsers display the readable form but may show Punycode for suspicious mixed scripts to counter lookalike attacks.
The specifications set no fixed maximum length, but practical limits exist in servers, proxies and tools. A widely used safe guideline is to keep URLs below about 2,000 characters, and many servers reject request lines above 8 KB by default.
Pitfalls and good practice
| Problem | Consequence | Remedy |
|---|---|---|
| Unencoded special characters | Broken parameters or wrong values | Encode each component separately |
| Sensitive data in query strings | Exposure in logs, history and referrers | Send it in request bodies or headers |
| Several URLs for one page | Duplicate content in search engines | Use one canonical URL and redirects |
| Changing URLs without redirects | Broken links and lost traffic | Permanent 301 or 308 redirects |
| Lookalike hosts | Phishing and credential theft | Check the registrable domain carefully |
Stable, readable URLs are part of good architecture. Short paths that reflect content, lowercase letters, hyphens between words and the absence of session identifiers make addresses easier to share, cache and index, and they should remain valid for years.
In everyday language
A URL is the full address of something on the internet, much like a postal address that names the country, city, street, house and apartment. The beginning says how to travel there, the middle names the building, and the end points to the exact room.
When you type or click a URL, your browser reads each part in order, finds the right computer, and asks it for that specific page, picture or file. A single wrong character leads somewhere else, which is why careful addresses matter.
Seen in the real world
A regional newspaper redesigns its website and changes article addresses from /article.php?id=48213 to readable paths such as /news/2026/city-council-approves-new-tram-line. Without care, thousands of incoming links from social networks, search results and other sites would break overnight.
The web team maps every old address to its new one and configures permanent 301 redirects, declares one canonical URL per article and strips tracking parameters from internal links. After launch, search traffic recovers within a few weeks, old links shared years earlier still open the right story, and the new addresses tell readers what an article is about before they click.