1. How the Web Works
How the Web Works
Before writing a single line of code, you need to understand what actually happens when you type a URL into a browser and press Enter. The answer is more elegant than you might think.
π The Client-Server Model
The web is built on a client-server relationship. Your browser (the client) sends a request across the internet to a server β a powerful computer sitting in a data center somewhere in the world. The server reads the request, finds the right files, and sends them back.
BrowserIP AddressGET /index.htmlHTML + CSS + JSVisible Page⨠The Holy Trinity of the Web
Every webpage is built from three technologies working together in perfect harmony:
The skeleton β defines structure and content
The skin β controls visual appearance
The muscles β adds interactivity and logic
π HTTP β The Language of the Web
Browsers and servers communicate using HTTP (HyperText Transfer Protocol). When your browser asks for a page, it sends an HTTP GET request. The server replies with a status code:
- 200 OK β Everything worked perfectly
- 404 Not Found β The page doesn't exist on the server
- 500 Internal Server Error β Something broke on the server
- 301 Moved Permanently β The URL has changed, follow this new one
π οΈ Tools You Need
- VS Code β The most popular code editor, free from Microsoft
- Chrome DevTools β Press F12 in any browser to inspect any website's code live
- Live Server extension β In VS Code, this auto-refreshes your browser every time you save a file
Knowledge Check
Ready to test your understanding of 1. How the Web Works?