/ Learning to code

What Is a Domain Name, and How Does It Work?

What is a domain name, and how does it work?

Almost everyone who uses the internet has heard of a domain name. But what exactly is a domain name, and how do they work? Should you have your own domain name?

No matter which Development Career Path you're following, it's important to understand the fundamentals of domain names. In this article (and in the video below), we'll answer all of your domain name-related questions. Use the table of contents to jump to a specific section.

What is a domain name?

A domain name is a unique string of text that's used to identify a specific resource on the internet. This could be anything from a website to an email or FTP server.

When you access a website, its domain name is converted to a set of numbers (an IP address) to communicate with the website server to send requests for and receive website content.

Domain names are designed for people

Everything could theoretically be handled using just IP addresses when you want to bring up a web page in your browser. In fact, adding a domain name adds an extra step in that there needs to be a way to convert from a domain name to an IP address (more on that below).

So, why do we use domain names at all?

Imagine that, instead of remembering everyone's name, you had to remember their phone number or social security number whenever you wanted to talk about them. Or imagine going into an electronics store and finding there are no more brands, device names, or model names. Everything just has a serial number that you have to remember if you want to buy it.

We, humans, are much better at remembering names than we are at remembering strings of digits. That's why we talk about catchy brand and model names, and that's why we use domain names instead of IP addresses.

What a domain name isn't

While you can use a domain name for a website or email account, it's not the same as a website or email itself. In other words, all websites and email accounts require a domain name, but having a domain name doesn't automatically mean that you have a website or email account.

What's in a domain name?

A domain name can be divided into two (or sometimes three) parts, each separated by periods.

Top-level domains

The top-level domain (TLD) is the two- or three-letter section to the right of the dot. In the domain name "Codecademy.com," ".com" is the TLD. Other common TLDs include:

  • .edu (for educational institutions)
  • .org (usually for non-profit organizations)
  • .gov (for government organizations)
  • .net
  • .io

The TLDs above are known as generic TLDs because they can be used by anyone around the world. But there are also country-specific TLDs, such as:

  • .ca (Canada)
  • .mx (Mexico)
  • .de (Germany)
  • .cn (China)
  • .jp (Japan)

While people are more or less free to choose other parts of their domain name (if they're not already in use), TLDs tend to be more restrictive. For example, you must be an accredited post-secondary institution to register a domain with the .edu TLD in the US. And, most countries restrict their TLDs to their own citizens or to businesses registered within their borders.

Second-level domain

The second-level domain (2LD) is what's to the left of the TLD. In the example of "Codecademy.com," "Codecademy" is the 2LD.

Third-level domain

Sometimes, a domain name has three parts. That is, three names separated by two dots. Think of British commercial websites, which always end in .co.uk. So, for Google's UK site, "Google.co.uk," ".uk" is the TLD, ".co" is the 2LD, and "Google" is the third-level domain (3LD).

A 3LD can also be used to designate a subdomain. For example, if you use Wikipedia in English, then you visit "en.Wikipedia.org." Here, ".org" is the TLD, "Wikipedia" is the 2LD, and "en" (for English) is the 3LD. Subdomains are often used to distinguish between different services. For example, take Google's subdomains like docs.google.com or drive.google.com.

The DNS: phonebook of the internet

Now that you understand why we use domain names and the anatomy of a domain name, you might be wondering how to convert a domain name to an IP address. That's where the Domain Name System (DNS) comes in.

The DNS is a global database of all the registered domain names on the internet. A DNS record will typically include the domain name and an associated IP address. Through the DNS, your browser can translate a domain name in the address bar into an IP address that it can then use to send requests to the web server and receive webpage content.

What's important to remember is that there's no single DNS server or even a single physical location for DNS servers. Instead, the DNS comprises a group of different servers located all around the world.

How your browser uses the DNS

To access an online resource and its content, your browser needs to communicate with multiple DNS servers. Lets' take a look at the process.

Recursive resolvers: the DNS librarian

Let's go back to the day when you visited Codecademy.com for the very first time. When you typed the domain name into your address bar, your browser had no idea where to go to access our homepage, let alone the webpage of this article. To fix this, the first step is to communicate with a recursive resolver.

Think of a recursive resolver as a librarian whose job is to communicate directly with the other DNS servers and come back to you with the query results. Recursive resolver servers communicate with three other types of DNS servers: root nameservers, TLD nameservers, and authoritative nameservers.

Root DNS nameservers

The highest level of a DNS query involves the root nameservers. Root nameservers contain information about where to find more information about the domain based on its TLD.

In our example of accessing Codecademy.com, a root nameserver would point the recursive resolver to the IP address of another DNS server with more information about websites that end in .com. In other words, the root server won't know the IP address of a domain, but it'll know where to go next to find more information.

There are 13 root servers located around the world, and they all contain information on where to find a domain's IP address based on the domain TLD.

TLD nameservers

The next step is for the recursive resolver to communicate with the TLD nameserver that was specified by the root nameserver. In our case of accessing Codecademy.com, the recursive resolver would communicate with a server that contains information about all websites that end in .com. The TLD nameserver will provide the recursive resolver with an IP address leading to the final part of the query, the authoritative nameserver.

Authoritative DNS nameservers

The final step is for the recursive resolver to communicate with the authoritative DNS nameserver, which contains information specific to the particular domain and is the final holder of the domain's IP address.

Once the recursive resolver has the IP address information it needs from the authoritative nameserver, it passes the results of the query back to your browser. Using the Codecademy domain IP address, your browser then communicates directly with the Codecademy.com server to load the Codecademy homepage and this very article.

Caching and other shortcuts

Now that you understand how your browser gets an IP address out of a domain name, you may be wondering how long this process takes. With so many back-and-forth queries through the recursive resolver, it can take a few seconds — sometimes more — to load a webpage every time you want to access it. Isn't there a faster way?

Once you access Codecademy.com or any other website for the first time, the query result is stored locally in your computer's cache memory. That way, the next time you visit the website on your computer, your browser already knows the IP address associated with its domain. This means it can connect directly with the web server instead of having to start another query with the recursive resolver.

Even if you're accessing a website for the first time, there's a chance that the recursive resolver already made a similar query recently. Maybe someone in your neighborhood is also advancing their development career with our courses.

In that case, the recursive resolver will have stored the query results and IP address in its own cache. Instead of going through a whole new DNS query with you, it can then just provide the IP address it got from its last query.

What's the difference between a domain name and a URL?

As you read this article, you might be looking up at the address bar and wondering whether that's all part of Codecademy's domain name. What you're actually looking at is the uniform resource locator or URL.

The URL contains the domain name ("Codecademy.com") and two other important pieces of information: the transfer protocol and the path. Note that some browsers, like Google Chrome, no longer display the full URL in the address bar. If you're using Chrome and can't see the full URL, right-click the address bar and click "Always Show Full URLs."

The transfer protocol (the "https://" to the left of the domain name) is the convention used between the computer and the server on the internet (in the case of most web traffic, the very common HTTPS protocol).

The path name contains information about a specific page or file within a website. For example, everything you see in your address bar to the right of "Codecademy.com/" is the URL path.

Just like a file path on your computer, the URL path for this article is unique and allows you to easily access this page later on or share it with your friends on social media.

Domain names versus web hosting

If you want to start your own website, you'll need to do two big things: register your domain name and find a place to host your website.

A web host provides a place for you to securely store your web content: your home page, photos, articles, and any other files that people see on your website. Whenever someone visits your website, they're accessing the information on the servers of your web host. Like everything else connected to the internet, your web host's servers are assigned their own IP addresses.

It's technically possible for you to host your own website on your own home computer or office server, but that's becoming less and less common.

When you register your domain, you're adding your domain name to the DNS so that people know it exists. Whether you use a web host provider or host your own website, you'll need to register your domain name. Otherwise, there'll be no way for the public to access your website except by using an IP address.

Think of it like starting a physical business. First, you need to register your business — apply for a business name, make sure that no one else is using your business name, and get a Tax ID number. But, you still need a place to do business, whether you're designating some space in your home or renting an office.

A web hosting service performs the same function. Even if you decide to change web hosting providers, you still keep your domain name. The only thing that changes is the physical server where your website files are stored.

Should you have your own domain name?

There are many advantages to having your own domain name. Not only are they affordable (which we'll get into later), but they also provide benefits such as:

A domain name gives you your own corner of the internet

There are many reasons why you might want your own domain name. Maybe you want a place to feature your resume or portfolio. Maybe you're looking to showcase a complex website you built yourself with languages like HTML, CSS, and JavaScript.

No matter what you intend to use it for, having your own domain name allows you to build a web presence that's entirely about you. There are no social media templates, word count limits, or distracting sidebars competing for readers' attention.

A domain name elevates you professionally

As you start networking and advancing your career, having your own website with your own domain name says a lot about you professionally. It means that you're taking your career seriously, not to mention that you have the skills to put together your own website.

While you can always list your GitHub, LinkedIn, and other social media profiles on a business card, think of how it'll be received. Almost everyone has a social media account, but having your own domain name speaks to your professionalism. Plus, with your own website and domain name, there's a single place for you to tell your professional story and present your portfolio the way you want to.

Domain name registrars and registries

We've gone over what domain names are, how they work, and why you should have one, but how do you actually get your own domain name? If you think of a catchy name for your personal site or business, how do you get it recorded in the DNS so that people can start using your domain name to access your website?

The truth is that having your own domain name is easier than ever before. Registration fees are only $10–$15 a year, and the registration process is quick and simple. And once you have your own domain name, you have immediate access to all the advantages that come with it.

To understand that better, let's first go over domain name registrars and registries.

Domain name registries

Registries are the organizations that manage the TLDs. For example, there are different registries for .com and .org domains, as well as separate registries for each country-specific domain. Registries keep records of which domains belong to which individuals or organizations at any given time.

The role of a registry is purely limited to record-keeping. When someone wants to buy a domain name, they must work with a registrar.

Domain name registrars

For commercial sales of registered domain names, registries delegate organizations called registrars to handle sales and customer interactions. When you buy a domain name, the registrar tells the registry to update its records and associate you or your company with that particular domain. Registries charge a fee to registrars for each domain registration, but that cost is passed to you via the registrar. So, all of your financial transactions are with the registrar, and it's the registrar who's responsible for customer service and support if there's a problem later on.

Domain name resellers

If you're looking to register a domain name, you may come across a reseller instead of a registrar. Resellers work on behalf of registrars and make money by receiving a portion of the registration fee.

While most resellers are legitimate, you should remember that resellers rarely offer the same level of customer support as registrars.

There's also domain squatting (AKA cybersquatting). In short, some people will buy domain names related to various businesses, organizations, and even celebrities in hopes of reselling them later for a profit.

Can you own a domain name?

While you hear a lot about people buying, selling, and owning a domain name, the reality is that the registry owns all of its registered domain names.

When you "buy" a domain, you're really leasing it or buying the right to reserve a domain name for your use for a certain amount of time — usually not more than 10 years. Still, it's always possible to keep renewing a domain name, which means that people and companies can effectively control it indefinitely.

Domain name security

Once you've acquired your own domain name, always follow good domain safety practices, such as:

Keep your domain name locked

Whenever your domain name is locked, it prevents anyone, including you, from making any changes to the information associated with it. If you do want to make any changes — for example, change the IP address that the domain points to after switching web hosting providers — then you need to unlock your domain name.

The problem is that an unlocked domain name can potentially be transferred to another registrar or third party and picked up by someone else. That's why it's important to unlock your domain name only when you absolutely need to.

Use a reputable domain registrar

Using a third-party domain name reseller to save some money can be tempting, but it's not worth the risk. Many third-party resellers have notoriously poor customer service, and if they go out of business, your domain name could be at risk of being transferred to someone else.

Register domain name variations

Even if your domain name is catchy and easy to remember, typos happen. The last thing you want is for a hiring manager or potential client to get an error message because they missed a letter when typing in your web address.

That's why you should consider registering domain name variations that redirect people to your website, even if they've mistyped something. For example, a lot of people misread or mishear Codecademy as "Code Academy." But, when they type in CodeAcademy.com, they're automatically redirected to the correct domain, Codecademy.com.

Similarly, say your domain ends in ".org," ".edu," or ".net." You might want to consider registering the ".com" variant as well to prevent competitors from doing the same.

Getting started with your website

Getting a domain name is an essential part of creating your own website, which you'll want to do if you want to stand out — especially as a Front-End Developer. If you're not sure how to start, our course on building websites will have you creating your own website in no time.


Web Development Courses & Tutorials | Codecademy
Web Development is the practice of developing websites and web apps that live on the internet. Whether you’re interested in front-end, back-end, or going full-stack, the content in our Web Development domain will help you get there.

Get more practice, more projects, and more guidance.

What Is a Domain Name, and How Does It Work?
Share this