> For the complete documentation index, see [llms.txt](https://security.navidnaf.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://security.navidnaf.com/potions/computer-networking/dns/domain-hierarchy.md).

# Domain Hierarchy

## What is Domain Hierarchy?

**Domain hierarchy** refers to the structured, layered organization of domain names within the **Domain Name System (DNS)**. It breaks down domain names into different levels, starting from the most general (root) to the most specific (subdomains). This hierarchy is read from right to left in a domain name.

## Components

<figure><img src="https://244896893-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTy5fNwfsaV6DbqjnheTF%2Fuploads%2FfEqN0fxNNEPFU2DE6V3x%2FBlank%20diagram%20-%20Page%201-10.png?alt=media&amp;token=5a73402f-08fc-4ea8-9b98-05c94cf66502" alt=""><figcaption></figcaption></figure>

### **Root (.)**

The topmost level of the hierarchy, often represented by an implicit dot at the end of a domain name. It doesn’t appear in URLs but is the starting point for DNS resolution.

### **Top-Level Domain (TLD)**

This is the first visible layer after the root and is the **rightmost part** of a domain name, such as:

* **Generic TLDs (gTLDs)**: `.com`, `.org`, `.net`, etc., which are used for general purposes and not restricted to specific countries.
* **Country Code TLDs (ccTLDs)**: `.uk`, `.jp`, `.us`, etc., which are used to represent specific countries or territories.

### Second-Level Domain (SLD)

The **Second-Level Domain (SLD)** is the part of the domain name immediately before the TLD, representing the main label for a website. Organizations and individuals register SLDs relevant to their brand or purpose, such as `example.com`or `amazon.co.uk`. SLDs are typically limited to 63 characters.

### Subdomains

**Subdomains** are labels added to the front of a domain name, sitting on the **left side** of the SLD. They allow website owners to create separate sections within their main domain, such as `blog.example.com` or `shop.google.com`. Subdomains follow the same creation restrictions as SLDs, including character limits, and are separated by periods from the main domain.

<figure><img src="https://lh7-us.googleusercontent.com/U4iIuef5IB-VI7L8mexREBB7QPAWmOSZMS_OZukaHjOUss24ayZeAEQdwnsJ7F-tTw6wZHOvJYIliR2RnJCLTHUAQkI39A-lLqmLLsv6aHDmrcykgujHK1Tw88N2b4wqcUt2FutcQ46c_k4A_RLcHaARB0o8TF9beTEvX4oVBBknyb8ah_F9fkOtpxM2iA" alt="" width="563"><figcaption></figcaption></figure>

## x.y.z.com

> Here, we will talk about - What is the difference between a third-level domain and a subdomain? For example, in **x.y.z.com**, how would the components be broken down?

In the domain `x.y.z.com`, the **third-level domain** and **subdomain** are essentially the same concept, though they are often described differently depending on the context.

| Entity | Hierarchy           | Explanation                                                                                                                                                                         |
| ------ | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| .com   | TLD                 | This is the highest level in the domain hierarchy, indicating the category or type of domain, such as `.com`, `.org`, or a country-specific TLD like `.uk`.                         |
| z      | SLD                 | This is the main domain name registered under the TLD. In this case, `z` is the second-level domain, which could represent a company or website.                                    |
| y      | Third-Level Domain  | This is the next level after the second-level domain. Here, `y` is considered the third-level domain because it is directly under the second-level domain (`z.com`).                |
| x      | Fourth-Level Domain | This is an additional subdomain under the third-level domain (`y.z.com`). The term "subdomain" is generally used to refer to any domain name that is part of a higher-level domain. |

### Key Difference

* **Third-Level Domain**: Refers specifically to the domain that comes after the second-level domain (e.g., `y` in `y.z.com`). It’s part of the domain hierarchy and is counted from the right.
* **Subdomain**: A broader term that refers to any domain that exists under a higher-level domain. In `x.y.z.com`, both `x` and `y` are subdomains of `z.com`, but `y` is also specifically the third-level domain.

In short, **all third-level domains are subdomains**, but not all subdomains are third-level domains. Subdomains can go beyond three levels (like `x.y.z.com`) and still be called subdomains.

**Note:** The maximum length of a domain name, including the TLD, is 253 characters. This includes the total length of the domain name and all its labels (e.g., `subdomain.example.com`). Each label within the domain name can be up to 63 characters long.
