Browsers and servers
The web is a network of computers that talk to each other. Your computer, phone, or tablet runs a browser, like Chrome, Safari, or Firefox. A server is a computer that stores website files and sends them out when asked.
When you visit a website, you are really asking a server to send you files. Those files are usually HTML, CSS, JavaScript, images, and videos. The browser reads those files and turns them into the page you see.
Key idea: the internet connects computers. The web is one service that runs on top of the internet, using browsers and servers.
Requests and responses
The conversation between browser and server follows a protocol called HTTP, or HyperText Transfer Protocol. The browser sends an HTTP request for a specific URL. The server sends back an HTTP response, which includes a status code and the requested content.
Common status codes include:
- 200 — OK, the page was found and sent.
- 404 — Not found, the server does not have that page.
- 500 — Server error, something went wrong on the server's side.
Every time you click a link, load an image, or submit a form, your browser sends another HTTP request.
Domain names and DNS
Computers identify each other using numbers called IP addresses, like 192.0.2.1 or longer IPv6 addresses. But humans are bad at remembering numbers, so we use domain names like codehs.com.
DNS, the Domain Name System, is like the phone book of the internet. When you type a domain, your browser asks a DNS server for the matching IP address. Once it has the address, it can contact the right server.
Files that make a page
A basic webpage is made of three kinds of files:
- HTML — the structure and content, like headings, paragraphs, and images.
- CSS — the style, like colors, fonts, and layout.
- JavaScript — the behavior, like buttons, animations, and data loading.
The server sends these files, and the browser combines them into the page. For static sites, the server sends the same files every time. For dynamic sites, the server may generate content on the fly, like a search result or a personalized feed.
Trace a request
Type a domain name below and click the buttons to watch a simplified version of what happens when you load a webpage.
// request log
A web request in Python
Every web page starts with a request. This Python program opens a TCP socket and sends the same GET request your browser sends.
Check yourself
Explain the difference between a browser and a server in your own words.
Your answer:
Sample answer: A browser is the program on your device that requests and displays web pages. A server is a computer that stores website files and sends them to browsers when asked.
Quick quiz
1. What does HTTP stand for?
2. What does DNS do?
3. Which file type controls the style of a webpage?
Keep learning
You understand the browser-server conversation. Next, learn about different kinds of hosting and which one fits your project.
First tutorial in the Web Hosting series.