Unays Learn · Web basics

How the web works: browsers, servers, URLs and HTTP

Before building websites it helps to know what happens between pressing Enter and seeing a page. This guide follows one request from your browser to a server and back.

Reading a URL

Take https://unays.net/learn/sql-basics/?print=1#join:

  • https is the scheme: the rules used to talk to the server.
  • unays.net is the domain: the name of the website.
  • /learn/sql-basics/ is the path: which page on that site.
  • ?print=1 is the query string: extra settings sent to the server.
  • #join is the fragment: a place on the page. It never leaves your browser.

Finding the server with DNS

Computers find each other by IP address, a number such as 203.0.113.7. The Domain Name System (DNS) works like a phone book: your device asks a DNS resolver "what is the address of unays.net?" and remembers the answer for a while so the next visit is faster.

Requests and responses

The browser then sends an HTTP request, which is plain text that looks like this:

GET /learn/ HTTP/1.1
Host: unays.net
Accept: text/html

The server sends back a response with a status code, headers and a body (here, the HTML of the page):

HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8

<!doctype html>...

The browser reads the HTML, notices the CSS, JavaScript and images it links to, and sends more requests for each of them.

Status codes

  • 200 OK: here is what you asked for.
  • 301 Moved Permanently: this page now lives at another address; the browser follows automatically.
  • 404 Not Found: no page exists at this path.
  • 403 Forbidden: the page exists but you are not allowed to see it.
  • 500 Internal Server Error: something broke on the server.

Codes starting with 2 mean success, 3 means redirect, 4 means a problem with the request and 5 means a problem on the server.

Why HTTPS matters

HTTPS encrypts the conversation, so people on the same Wi-Fi network cannot read or change what you send, such as passwords. The padlock in the address bar means the connection is encrypted and the site proved it owns the domain. It does not prove the site is honest, so still check the address before typing a password.

Try it yourself

Open your browser's developer tools (F12), choose the Network tab and reload this page. Click the first request to see its status code and headers, then count how many extra files the page loaded. Next, build your own page with your first HTML page.

This tutorial was written with AI assistance and reviewed by Unays. The runnable code examples were tested before publishing. Spotted a mistake? Tell us at [email protected].