What is a subdomain?

A subdomain is any name beneath a registered domain, such as blog.example.com under example.com. The domain owner creates it in the DNS zone; nothing has to be registered.

Once you hold example.com you control everything to the left of it. Creating a subdomain is just adding a record, for instance an A record for blog.example.com or a CNAME for shop.example.com, and you can go several levels deep (api.eu.example.com). Each subdomain can point to a different server or provider.

A subdomain can also be delegated: by adding NS records for it, you hand a whole branch, for example dev.example.com and everything below it, to other nameservers that are managed separately. A wildcard record (*.example.com) answers for every subdomain that has no record of its own.

Strictly speaking www is a subdomain like any other. Two practical cautions: cookies and TLS certificates are scoped by hostname, so each subdomain must be covered by a certificate, and a CNAME left pointing at a cancelled third-party service can let someone else claim that service name and serve content on your subdomain (a subdomain takeover). Remove DNS records when you retire the service behind them.

Example

blog.example.com.      300  IN  A      192.0.2.20
api.eu.example.com.    300  IN  CNAME  lb.hosting.example.

Check it

See how Subdomain looks for a real domain:

DNS lookup