FreeLesson 1 of 36 min read
From URL to web page: what your browser really does
Follow a web address step by step, from DNS lookup to the moment the page appears on screen.
You type an address, press Enter, and a page appears in about a second. A lot happens in that second. Once you understand the steps, it becomes much easier to fix a broken site or make a slow one faster. It also explains words like DNS, HTTPS and server that you will meet in every web project.
Let's follow one request from start to finish.
Reading the address
A web address is called a URL. The browser first splits it into parts so it knows what to ask for and who to ask.
Example: breaking down a URL
https://www.example.com/books/index.html
https = the scheme, or protocol: how to talk (securely, using HTTP)
www.example.com = the domain: which server to talk to
/books/index.html = the path: which page to ask that server for
Finding the server with DNS
Computers on the internet find each other using numeric IP addresses, not names. So the browser needs to turn www.example.com into a number. That is the job of DNS, the Domain Name System. It works like a phone book for the internet.
The browser first checks whether it already knows the answer from a recent visit. This saved copy is called a cache. If not, it asks a DNS resolver, usually run by your internet provider or a public service. The resolver finds the IP address and sends it back.
Opening a connection
Now the browser knows where the server is. It opens a connection to it, normally using a protocol called TCP, which makes sure data arrives complete and in order. Because the URL starts with https, the browser and server also run a TLS handshake. They agree on encryption keys, and the browser checks the server's certificate to confirm it really is www.example.com. From here on, everything sent between them is encrypted.
Sending the request and getting a response
With the connection ready, the browser sends an HTTP request. It is just structured text. It names a method (GET means "please give me"), the path and some extra details called headers.
GET /books/index.html HTTP/1.1
Host: www.example.com
Accept: text/html
The server reads this, finds or builds the page and replies with an HTTP response. The first line holds a status code. 200 means success. Then come headers that describe the content, a blank line, and the body, which here is HTML.
HTTP/1.1 200 OK
Content-Type: text/html
<html>
<head><link rel="stylesheet" href="/style.css"></head>
<body><h1>Our books</h1><img src="/cover.png"></body>
</html>
Turning HTML into a page
The browser now reads, or parses, the HTML from top to bottom. As it goes, it finds references to other files: a stylesheet, an image, perhaps some JavaScript. Each one needs its own request to the server. When enough has arrived, the browser works out the layout and paints the pixels on your screen. JavaScript may then run and change the page further.
The whole journey in short:
- Split the URL into scheme, domain and path.
- Use DNS to turn the domain into an IP address.
- Open a connection, encrypted with TLS for HTTPS.
- Send an HTTP request and receive a response.
- Parse the HTML, fetch extra files, then draw the page.
Next time you visit a site, try to name each step as it happens. In the next lesson, you will see that apps use these same HTTP requests to fetch raw data instead of whole pages.
Key takeaways
- DNS turns a domain name into the IP address of a server.
- The browser and server talk using HTTP requests and responses, encrypted by TLS when the URL uses HTTPS.
- One page usually needs many requests, because CSS, images and scripts are fetched separately.
Check your understanding
Written with AI help. Spotted a mistake? Tell us.