Skip to content
SparkTime, home

Guide · Technology

How a Website Works: From Typing a URL to Seeing the Page

What really happens in the second between pressing Enter and seeing a page? A plain walk through DNS, servers, HTTP, HTML, CSS and JavaScript, with no jargon left unexplained.

5 min readBeginner

For

Beginners, students and non-developers who want to understand how the web works.

Level

Beginner
On this page

Key takeaways

  • A website is files and programs on someone else's computer (a server) that your browser asks for using HTTP.
  • DNS turns a name such as example.com into the server's numeric address.
  • The browser builds the page from HTML (structure), CSS (looks) and JavaScript (behaviour).
  • A backend runs code and talks to a database to produce dynamic pages and data.
  • HTTPS encrypts the connection so others on the network can't read or change what is sent.

You type example.com and press Enter. A moment later, a page appears. Behind that moment, a dozen things happen across several computers. Understanding them makes everything else in web development easier.

The cast

#
  • You and your browser (Chrome, Firefox, Safari, Edge): the client.
  • A server: a computer connected to the internet that stores the site and answers requests.
  • DNS: the internet's phone book.
  • The network: cables, routers and your internet provider carrying data between you and the server.

Step 1: You enter a URL

#

A URL has parts:

Code
https://www.example.com:443/blog/post-1?lang=en#comments
  • https: the protocol (rules for talking)
  • www.example.com: the domain name
  • :443: the port (usually hidden)
  • /blog/post-1: the path to a page or resource
  • ?lang=en: query parameters
  • #comments: a fragment pointing to a spot in the page

Step 2: DNS finds the server

#

Computers talk with numbers called IP addresses (such as 93.184.216.34). People prefer names. The Domain Name System (DNS) translates one to the other.

Your browser checks its own cache, then asks your device, then a DNS resolver (often your internet provider's or a public one), which asks other DNS servers until it gets the answer. This takes milliseconds and the result is cached for a while.

Step 3: The browser connects to the server

#

Your browser opens a connection to that IP address, using TCP (a reliable transport). With HTTPS, it then agrees on encryption using TLS, the technology that gives the padlock.

During this, the server proves its identity with a certificate issued by a trusted authority. This is how your browser knows it's talking to the real example.com and not an impostor, and why nobody on public Wi-Fi can read your passwords.

Step 4: The browser sends an HTTP request

#

HTTP is the language of the web. The browser sends a request such as:

Code
GET /blog/post-1 HTTP/1.1Host: www.example.comAccept: text/html
  • GET means "give me this". Other common methods are POST (send data), PUT/PATCH (change) and DELETE.
  • Headers carry extras: language, cookies, the type of content wanted.

Step 5: The server prepares a response

#

The server may do very little or a lot:

  • Static site: it finds a file on disk (post-1.html) and sends it.
  • Dynamic site: it runs code (the backend, written in languages such as Node.js, Python, Java, PHP or Go), possibly asks a database for data, builds the HTML and sends it.

For a social media feed, the backend checks who you are (from a cookie or token), fetches your posts from the database, and returns a page or data.

If you want to understand how apps and servers exchange data, read what is an API.

Step 6: The response comes back

#

The server replies with:

  • A status code: 200 OK, 301 (moved), 404 (not found), 500 (server error).
  • Headers: content type, caching rules, cookies.
  • A body: usually HTML.

Status codes are useful clues when debugging. See how to debug any bug.

Step 7: The browser builds the page

#

The browser reads the HTML and creates a tree of elements. It then sees links to other files and requests them too:

  • HTML: the structure and content. Headings, paragraphs, links, images, forms.
  • CSS: the appearance. Colours, fonts, spacing, layout, and how it adapts to phone screens.
  • JavaScript: the behaviour. Menus that open, forms that validate, content that loads without refreshing.
  • Images, fonts and videos: fetched as separate requests.

A single page can involve dozens of requests. Browsers fetch many in parallel, and use caches so repeat visits are faster.

Then it renders: calculating layout, painting pixels and responding to your clicks.

Frontend and backend

#
  • Frontend: what runs in your browser (HTML, CSS, JavaScript, and frameworks such as React). It handles what you see and touch.
  • Backend: what runs on the server (application code, business rules, authentication, databases).
  • Full-stack developers work on both.

They talk to each other with APIs, usually exchanging JSON.

A trip with a login

#

Suppose you log in to a site:

  1. You fill in a form and press the button.
  2. The browser sends a POST request with your email and password (encrypted by HTTPS).
  3. The server checks the password against a stored hash (never the plain password).
  4. If it's right, the server creates a session and sends back a cookie.
  5. On each later request, your browser sends the cookie, so the server knows who you are.

Where the site lives: hosting

#

Someone has to run the server.

  • Shared hosting: cheap, many sites on one machine.
  • Cloud platforms (AWS, Azure, Google Cloud): rent computers by the hour. See cloud computing explained.
  • Platforms like Vercel or Netlify: deploy a site from Git and let the platform handle servers. If you're new to Git, start with Git for beginners.
  • CDN (Content Delivery Network): copies of your files stored in many cities so users get them from a nearby location.

A domain name is separate: you rent it from a registrar and point it at your hosting through DNS records.

Why sites are slow, and what helps

#
  • Large images and videos. Compress and use modern formats.
  • Too many scripts.
  • A distant server. Use a CDN or a closer region.
  • Slow database queries.
  • No caching.

Browser developer tools (press F12) have a Network tab that shows every request, its size and its time. It's a good place to be curious.

Try it yourself

#
  1. Open any website and press F12.
  2. Go to the Network tab and reload the page.
  3. Click the first request and look at the request and response headers.
  4. Switch to the Elements tab and see the HTML tree.
  5. Right-click an element, choose Inspect and change some text. You're editing your own copy of the page.

Frequently asked questions

#

What's the difference between the internet and the web?

#

The internet is the global network of computers. The web is a service on top of it, made of pages and links, accessed through browsers using HTTP.

#

A small piece of data a site stores in your browser. It remembers login sessions, preferences and similar things.

What does HTTPS actually protect?

#

It encrypts the data between your browser and the server and verifies the server's identity. It doesn't mean the site itself is trustworthy, only that the connection is private.

What's a "CDN"?

#

A network of servers across the world that stores copies of your files, so they load faster from nearby.

Where should I start if I want to build websites?

#

Learn HTML, CSS and a bit of JavaScript, then build small projects. If you're unsure how to learn in an age of AI tools, read learning to program in the AI era.


Simplified for understanding. Real systems add layers such as load balancers, caches and security checks.

Sources & further reading

  1. MDN Web Docs, how the web works
  • Guide · Technology

    HTTP, JSON and REST APIs: How Web Backends Talk

  • Guide · Technology

    Security Fundamentals and Spring Security: Passwords, JWT, Access Control, CORS and Secrets

  • Guide · Career

    A LinkedIn Profile That Gets Recruiter Messages