← Glossary

What Is a Uniform Resource Locator (URL)?

A URL is the address that tells a client which protocol to use, which host to contact and which resource to request. This article walks through the components of one example URL, explains how browsers parse and use each part, distinguishes URLs from domain names and URIs, and notes where URLs can leak sensitive data.

Updated:

A uniform resource locator (URL) is a string that tells a client how to reach a specific resource: for a typical web address, which protocol to speak, which host to contact, and which resource to request. It is the text typed into a browser's address bar, the target of every link, and an address used by network requests and many web APIs. A URL does more than name something; it locates it, which is the property that separates it from other kinds of identifiers.

Throughout this article one example is used: https://shop.example.com:8443/catalog/shoes?color=black&page=2#reviews. It includes the main components of an HTTPS URL, without embedded login credentials. Most real URLs omit the port and the fragment, and many omit the query as well.

Parts of a URL

Both the WHATWG URL Standard, which browsers implement, and RFC 3986, the older generic URI syntax, break a URL into the same ordered pieces.

ComponentIn the exampleRole
SchemehttpsProtocol and rules for interpreting the rest
Hostshop.example.comServer to contact, as a domain name or IP address
Port8443Network port; omitted when the scheme's default applies
Path/catalog/shoesResource within the host
Querycolor=black&page=2Parameters the server may use
FragmentreviewsLocation inside the resource, handled by the client

The URL scheme comes first and ends at the colon. It determines how everything after it is parsed and which protocol the client uses. https and http are the common web schemes, but mailto, file, ftp and ws have their own parsing rules; mailto, for example, does not use the web-style host and path structure. The URL Standard calls http, https, ws, wss, ftp and file special schemes and assigns default ports to most of them: 80 for http and ws, 443 for https and wss, 21 for ftp.

The hostname and path do different jobs. The hostname identifies the server and is normally resolved to an IP address for a network connection, sometimes using a cached result or resolution performed by a proxy. The path identifies the resource on that server. Historically the path mapped to a file on disk; today it is usually an abstract route that the server's application interprets, so /catalog/shoes need not correspond to any folder. An optional username and password may precede the host, separated by an at sign, but embedding passwords this way is deprecated in RFC 3986 and unsafe for ordinary web links.

Query parameters follow the question mark, commonly as key-value pairs separated by ampersands; generic URL syntax does not require that structure. The server decides what they mean; page=2 might select the second page of results or be ignored entirely. The fragment after the hash sign points to a position inside the retrieved resource, typically an element id on an HTML page. It is not part of the HTTP request target, although page scripts can read it and send its contents elsewhere.

How Browsers Resolve and Use URLs

For a fresh HTTP/1.1 or HTTP/2 connection to the example URL, the browser first parses the string into its components, applying the URL Standard's rules for percent-encoding, case normalization of the scheme and host, and removal of dot segments such as ../ from the path. It then resolves shop.example.com through DNS, opens a TCP connection to port 8443, negotiates TLS because the scheme is https, and sends an HTTP request whose target is the path plus the query: /catalog/shoes?color=black&page=2. The fragment is stripped before the request is built. Once the page arrives, the browser scrolls to the element with id reviews on its own if that element exists. HTTP/3 can instead carry HTTPS over QUIC using UDP, and an existing connection can avoid a new connection setup.

Relative URLs are resolved against a base URL, normally the containing document's URL unless the page specifies another base. A link written as boots on the example page becomes https://shop.example.com:8443/catalog/boots; one written as /cart keeps the scheme, host and port but replaces the path; one written as #sizing changes only the fragment and triggers no new request. This resolution happens entirely in the browser, which is why moving a site to a new domain can break absolute links while relative ones keep working.

Browsers also use URLs as keys. URLs help identify cached responses, history entries and bookmarks. Caches can also distinguish responses by request headers and other context. For ordinary HTTP and HTTPS URLs, the origin used for security decisions is the scheme, host and port taken together. Two such URLs that differ only in query or fragment share an origin; two that differ in scheme or port do not.

URLs vs Domain Names and URIs

A domain name is one possible value of the host component. example.com is a domain; https://example.com/ is a URL that uses it. A domain name alone says nothing about protocol, port or resource, and the same domain can appear in millions of distinct URLs. Replacing the hostname with an IP address produces a valid URL as well, which shows that the domain is a convenience inside the URL rather than the URL itself.

The relationship between URL and URI is largely historical. RFC 3986 defines the uniform resource identifier as the general class and treats URL as the subset that also describes how to locate the resource, with URN covering persistent names such as urn:isbn:0451450523. The WHATWG URL Standard, written to match what browsers actually do, uses the single term URL for everything and aims to supersede the earlier RFCs for web use. In practice, web developers say URL, standards documents outside the browser world may say URI, and both usually mean the same string.

Common Uses and Limitations

URLs are the addressing layer of the web: they appear in links, redirects, API endpoints, sitemaps and analytics. Readable paths such as /catalog/shoes help users predict where a link leads and help search engines understand page structure. Query parameters carry search terms, filters and pagination, and are frequently used for campaign tracking.

The limitations are mostly about exposure. A URL can be recorded in browser history, server logs, analytics and copied links. The Referer header can also expose its path and query, depending on policy; the usual strict-origin-when-cross-origin default sends only the origin to another origin. HTTPS protects the path and query in transit from ordinary network observers, but not from the destination or browser. A session token or personal identifier in a query therefore needs careful handling. Password-reset links are a deliberate exception in some systems, typically with short-lived, single-use tokens and restricted logging. Credentials embedded in the userinfo part are worse still and are rejected or stripped by many clients. URLs also break: resources move, hosts change, and a locator that pointed somewhere last year may return an error today. A URL promises a route to a resource, not the resource's permanence.

Frequently asked questions

Is a URL the same as a domain?

No. A domain name such as example.com is only the host part of a URL. A complete URL adds the scheme, an optional port, a path and possibly a query and fragment. One domain can appear in an unlimited number of URLs, and a URL can use an IP address instead of a domain.

What is a URL fragment?

The fragment is the part after the hash sign, such as #reviews. Browsers leave it out of the HTTP request target and usually use it to locate an element or drive page behaviour. It is not a secure place for secrets: a page script can read it and transmit it separately.

Can a URL contain sensitive data?

It can. Paths and queries may appear in history, logs, analytics and copied links. Referrer policy controls what subsequent requests disclose; modern defaults generally omit paths and queries on cross-origin requests. HTTPS protects transit but does not prevent endpoint logging. Secret credentials usually belong in protected headers or request bodies.

Why is the port usually missing from a URL?

Common network schemes define default ports: 80 for HTTP and 443 for HTTPS, for example. Browsers use those when a port is omitted. An explicit 8443 selects a different port. Not every scheme has a port: file URLs, for instance, do not follow this network-port pattern.

What is the difference between a URL and a URI?

In RFC 3986 a URI is the general identifier class and a URL is the subset that also tells a client how to locate the resource. The WHATWG URL Standard used by browsers folds both into the single term URL. For web addresses the two words refer to the same string.