What happens when you type a URL and press Enter
Typing a URL and pressing Enter starts a chain of small, separate jobs. The one idea to keep: the browser first finds the server, then talks to it, then draws what it gets back.
The short version
A URL tells the browser three things: which protocol to use, which server to ask, and which resource to ask for. The browser looks up the server's address, opens a connection to it, sends a request, and turns the HTML in the reply into the page you see.
Step by step
- The browser reads the URL:
httpsis the scheme,example.comthe server,/the path. With no port written, HTTPS uses 443. - It asks DNS for the server's IP address.
- It opens a TCP connection with a three-way handshake, then a TLS handshake that checks the server and sets up encryption.
- It sends an HTTP GET request for the page, and the server replies with headers and HTML.
- It parses the HTML into a tree (the DOM), fetches the CSS, scripts and images it finds, then lays out and paints the page.
Why it matters
Steps 2 to 4 are messages over the network, and all of them happen before you see a single pixel. That is why a slow DNS answer or a slow connection can delay a page that is itself small.
Sources
- MDN, Populating the page: how browsers work — DNS lookup, TCP and TLS handshakes, the GET request, parsing into the DOM, fetching linked resources, layout and paint
- MDN, What is a URL? — scheme, domain, path, default ports 80 and 443
- RFC 9293, Transmission Control Protocol — the three-way handshake (section 3.5)