All posts
Networking

What Really Happens When You Type a URL Into Your Browser

The classic senior-interview question answered in depth: DNS, TCP, TLS, HTTP, and the rendering pipeline — every hop from keystroke to pixels.

SKSushan Khadka
April 22, 2026 (4mo ago)5 min read
What Really Happens When You Type a URL Into Your Browser — article by Sushan Khadka (namelessnerd)

It is the interview question that separates people who use the web from people who understand it. Type a URL, hit Enter — and a dozen systems light up in sequence before a single pixel appears. Here is the honest version.

What Really Happens When You Type a URL Into Your Browser - diagram by Sushan Khadka (namelessnerd)

Before a single packet leaves

The work starts in the browser, before the network is even touched. As you type, the browser is already deciding whether your text is a URL or a search query, checking its autocomplete history, and — crucially — consulting the HSTS preload list. If the domain is on that list, the browser upgrades http:// to https:// locally, so it never sends an insecure request that could be intercepted and downgraded.

Then it parses the URL into its parts — scheme, host, port, path, query — and checks its own caches. Is there a fresh copy of this page already? A still-valid DNS answer? A warm connection to this host it can reuse? Every cache hit here is a network round trip you get to skip. Only what is left over actually goes out on the wire.

The hop sequence

Four phases, strictly in order: DNS → TCP+TLS → HTTP → render.

DNS: turning a name into an address

Your machine runs a stub resolver that offloads the real work to a recursive resolver (your ISP's, or something like 1.1.1.1). If the answer isn't cached, that recursor walks the hierarchy: a root server points it at the .com TLD servers, which point it at the authoritative server for example.com, which finally returns the record. The answer is cached at every layer for the length of its TTL, so most lookups short-circuit long before reaching the root.

Only now do you have an IP address. And notice: nothing has been fetched yet. You have merely learned where to knock.

TCP and TLS: opening a secure pipe

TCP establishes the connection with a three-way handshake — SYN, SYN-ACK, ACK, one round trip — giving both sides an agreed starting point and reliable, ordered delivery.

On top of that, TLS negotiates encryption. In TLS 1.3 this is a single additional round trip: the client sends its supported ciphers and a key share, the server picks one and returns its own share and certificate, and both sides derive the same session key without ever transmitting it. The browser also validates the certificate here — checking the chain of trust up to a root CA, the hostname, and the expiry — which is what turns "encrypted" into "encrypted and talking to the right server."

HTTP: finally, the request

With a secure pipe open, the browser sends the actual request:

GET /index.html HTTP/2
Host: example.com
Accept: text/html
Accept-Encoding: gzip, br

The server responds with a status code and the body. That first HTML document is just the beginning — as the parser reads it, it discovers references to CSS, JavaScript, images, and fonts, and fires off requests for each. This is why the number of resources and the order they are discovered matters so much for speed, and why HTTP/2 and HTTP/3 multiplex many of them over a single connection instead of queuing.

Render: from bytes to pixels

The browser now runs its pipeline. It parses HTML into the DOM tree and CSS into the CSSOM, combines them into a render tree of what is actually visible, computes layout (the exact position and size of every box), paints pixels into layers, and composites those layers onto the screen — often on the GPU.

A subtlety that bites everyone: <script> tags block HTML parsing by default, because a script might rewrite the document. CSS blocks rendering, because painting with the wrong styles would flash unstyled content. This is the whole reason async/defer on scripts and inlining critical CSS exist — they stop a single blocking resource from freezing the entire pipeline.

The dirty secret: it is mostly waiting

Most of the time you "wait for the page" is not the server computing anything — it is round trips. DNS lookup, TCP handshake, TLS handshake, then the request itself: each is a packet flying across continents and back.

Server processing is often a few milliseconds. The latency is geography and the speed of light — a packet from London to Sydney and back cannot beat physics no matter how fast your backend is. This is why a CDN edge node 20ms away beats an origin 200ms away, every single time, and why the entire discipline of web performance is really a war on round trips.

How modern stacks cut the trips

Once you see the web as a pile of round trips, every optimization makes sense as a way to delete one.

The takeaway

Read more posts