Skip to content

What is a subdomain? How it differs from a domain and a subdirectory

Better Design

Direct answer

A subdomain is a name added in front of a domain you control, such as blog.example.com, and you create it with a DNS record. This guide explains how subdomains, domains and subdirectories differ, from MDN and Cloudflare's developer docs.

A hand-drawn browser window with Subdomain written in it and a short list of what it does.

Subdomain: what to know

Each rule is listed with its source at the end of this page, read on November 12, 2026.

  • A subdomain is a name you add in front of a domain you control, such as developer.mozilla.org under mozilla.org.
  • The owner of a domain defines its subdomains, and each subdomain can hold different content.
  • Each part of a domain name is a label of 1 to 63 characters, using letters, digits and hyphens.
  • The label right before the top-level domain is the second-level domain, such as mozilla in mozilla.org.
  • Common uses are blog.example.com for a blog, support.example.com for a help portal and store.example.com for a shop.
  • www is itself a subdomain, and it usually points to the same content as the apex domain or redirects to it.
  • You create a subdomain with a DNS record: an A record for an IPv4 address, an AAAA record for an IPv6 address, or a CNAME record for another hostname.
  • In that record, the subdomain label, such as blog, is the record name.
  • Your hosting provider must be able to serve content for the subdomain before the record will work.
  • A subdirectory is part of the URL path, such as /blog in example.com/blog, and the web server handles it rather than DNS.
  • On Cloudflare, a Universal SSL certificate covers first-level subdomains such as blog.example.com but not deeper ones such as dev.blog.example.com.

Domain, subdomain and subdirectory compared

Top-level domain
Example

.org in mozilla.org

Who controls it

A registry; the list is maintained by ICANN

Domain
Example

mozilla.org

Who controls it

The person who registers it through a registrar

Subdomain
Example

developer.mozilla.org

Who controls it

The domain owner, through a DNS record

www subdomain
Example

www.example.com

Who controls it

The domain owner; it usually points to the apex domain

Subdirectory
Example

example.com/blog

Who controls it

The web server, as part of the URL path

Put Subdomain into practice

  • Choose a label for the subdomain, such as blog or shop.
  • Make sure your host can serve content for that hostname.
  • Open the DNS settings at your DNS provider.
  • Add an A, AAAA or CNAME record with the label as the record name.
  • Save the record and load the new address in a browser.

Subdomain in four steps

The four steps, in the order you take them.

A hand-drawn four-step path for Subdomain: Register domain, Choose label, Add DNS record, Point to host.
  1. Step 1: Register domain
  2. Step 2: Choose label
  3. Step 3: Add DNS record
  4. Step 4: Point to host

Caveats to keep in mind

  • A DNS record alone does not serve a site; the host must also accept the hostname.
  • A certificate that covers first-level subdomains may not cover deeper ones such as dev.blog.example.com.
  • Without a www record, visitors who type www. before your domain may not reach your site.
  • You do not buy a subdomain separately; you create it under a domain you already control.

Steal this workflow

Run this guide in your own assistant. The prompt carries the guide link and the workflow summary, so the assistant can adapt it to your project.

Read the guide "What is a subdomain? How it differs from a domain and a subdirectory" at https://better-design.com/blog/what-is-a-subdomain and help me apply it to my project.

A subdomain is a name added in front of a domain you control, such as blog.example.com, and you create it with a DNS record. This guide explains how subdomains, domains and subdirectories differ, from MDN and Cloudflare's developer docs.

Start by asking what I am building and which tools I use. Then walk me through the workflow step by step, adapted to my answers.

Claude and ChatGPT open with the prompt filled in. Gemini copies the prompt to your clipboard first, so paste it when the app opens.

Questions

What is the difference between a subdomain and a subdirectory?

A subdomain is part of the host name, like blog.example.com, and DNS sends it to a server. A subdirectory is part of the path, like example.com/blog, and the web server for example.com handles it.

Is www a subdomain?

Yes. www is a subdomain that the domain owner sets up. It usually points to the same site as the apex domain or redirects to it.

How do I create a subdomain?

Add a DNS record at your DNS provider. Use an A or AAAA record to point to an IP address, or a CNAME record to point to another hostname, and use the subdomain label as the record name.

Where these rules come from

Each fact comes from MDN Web Docs and Cloudflare's developer documentation, read on November 12, 2026.

Build the interface in your own code instead

A coding agent such as Claude Code, Cursor or Codex can build these screens in your own code. Better Design gives that agent a design system, interface principles and review rules, so the result follows rules like these and looks designed.