What Is the Difference Between a Website, a Hostname, and a Domain?

Learn the difference between a hostname, a domain, and a website, with URL examples and a clear explanation of subdomains and DNS records.

Published
Reading time
6 min read
What Is the Difference Between a Website, a Hostname, and a Domain?
On this page

A domain name, a hostname, and a website are related, but they are not interchangeable. In a hostname vs domain vs website comparison, the simplest distinction is this: a domain is a name in the DNS hierarchy, a hostname identifies a host by name, and a website is the collection of pages and resources people access on the web.

Key Takeaways

  • example.com is a domain name. shop.example.com is a subdomain and can also be a hostname.
  • A hostname is the host portion of a URL; it does not include the protocol, port, path, query, or fragment.
  • DNS records help translate names into information such as IP addresses. They do not contain the website itself.
  • A website can use more than one hostname, and a domain can be used for services other than a website.

Domain vs hostname vs website

TermPlain-language meaningExample
Domain nameA name in the hierarchical Domain Name System (DNS).example.com
HostnameA name used to identify a host on a network.shop.example.com
WebsitePages and other resources presented together on the web.An online store served at https://shop.example.com/

These categories overlap. For example, shop.example.com is a domain name under example.com; when used to identify a host, it is also a hostname. Likewise, example.com can be a hostname when it is used as the host in a URL.

In everyday conversation, people often say “domain” to mean the name they registered, such as example.com, and “hostname” to mean a name beneath it, such as www.example.com. That distinction is useful, but it is not a strict rule: a registered domain name can also be used as a hostname.

Advertisement

Find the hostname in a URL

Consider this illustrative URL:

https://shop.example.com:8443/products?color=blue#details
PartValuePurpose
SchemehttpsIndicates how the browser accesses the resource.
Hostnameshop.example.comNames the host the browser is trying to reach.
Port8443Selects a network service on the host.
Path/productsIdentifies a resource on the website.
Querycolor=blueSupplies additional parameters.
FragmentdetailsIdentifies a location or part of the resource for the client.

The hostname is only shop.example.com. The :8443 port is part of the URL's host-and-port portion, but it is not part of the hostname. A URL may also omit the port, in which case the scheme's default is normally used.

How domains and subdomains fit together

DNS names are arranged in a hierarchy. In shop.example.com:

  • com is a top-level domain.
  • example.com is a domain under com.
  • shop.example.com is a subdomain of example.com.

A subdomain can have further subdomains, such as help.shop.example.com. Names are read from the most specific label on the left toward broader levels on the right.

A subdomain is not automatically a separate website. www.example.com and shop.example.com could serve different websites, different parts of one website, or no website at all. The outcome depends on DNS and how the relevant servers and applications are configured.

Also, the registrable portion of a name is not always simply its last two labels. Registration rules vary; for example, some names are registered beneath a two-label public suffix.

What DNS records do

DNS provides records associated with domain names. A browser commonly uses DNS to find an address for a hostname before connecting to a server. Here are fictional records for illustration:

example.com.       A      192.0.2.10
shop.example.com.  CNAME  example.com.
example.com.       MX     10 mail.example.com.
  • An A record associates a name with an IPv4 address. An AAAA record can provide an IPv6 address.
  • A CNAME record makes one name an alias of another name. Here, a lookup for shop.example.com can follow the alias to example.com.
  • An MX record identifies a mail server for a domain; it is not a website address.

The trailing dots in the example make the DNS names explicitly absolute. The address 192.0.2.10 is a documentation example, not a working website address.

DNS does not store the website's pages in these records. After resolving a hostname, the browser connects to a service, which may return website content over HTTP or HTTPS. A DNS record alone does not guarantee that a website exists, that the server is reachable, or that HTTPS is configured correctly. Servers can also use the requested hostname to decide which website to serve.

Advertisement

A practical way to distinguish them

Suppose a small business uses example.com:

  1. The business manages the domain example.com.
  2. It configures www.example.com as a hostname for its public site.
  3. DNS records direct that hostname toward the service hosting the site.
  4. The website is the content visitors see after their browsers connect: pages, images, and other resources.
  5. The business might also use the domain for email, which is a separate service from the website.

If the website moves to a different provider, its content and server configuration may change, and its DNS records may need updating. The domain name itself can remain the same.

Common Mistakes

  • Calling the entire URL a hostname. In https://www.example.com/about, the hostname is www.example.com, not the scheme or path.
  • Assuming every subdomain is a separate website. A subdomain is a name; what it serves depends on configuration.
  • Treating DNS as website hosting. DNS helps clients locate services; the web service delivers the content.
  • Assuming a hostname must start with www. Names such as example.com and shop.example.com can also be hostnames.
  • Assuming DNS resolution means a site works. Network access, server configuration, and HTTPS can still cause failures.

Best Practices

When configuring a site, write down the exact hostname users should visit and check its DNS records separately from the website's server configuration. If both example.com and www.example.com should work, configure and check both; one does not automatically follow from the other.

Conclusion

A domain is a DNS name, a hostname is a name used to identify a host, and a website is the content and resources served to visitors. The same name can be both a domain and a hostname, but neither term by itself means the website.

Source limitation: Authoritative DNS documentation was not accessible for this draft. For further checking, consult RFC 1034 and RFC 1035 for DNS terminology and the WHATWG URL Standard for URL terminology; those sources were not retrieved for this article.

What would your domain sell for?

A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.