Module 0

How the Web Works

Browsers β€’ Servers β€’ DNS β€’ HTTP β€’ DevTools

🌐 What Happens When You Type a URL?

Every time you visit a website, an incredible chain of events unfolds in milliseconds. Before writing a single line of HTML or CSS, it helps to understand what's actually happening behind the scenes.

In this module, you'll learn about the key players β€” browsers, servers, DNS, and HTTP β€” and see how they work together to deliver web pages to your screen.

The Journey of a Web Request

⌨️
You type a URL
β†’
πŸ”
DNS finds the IP
β†’
πŸ“‘
HTTP request sent
β†’
πŸ–₯️
Server responds
β†’
🎨
Browser renders

🎯 By the end of this module, you will:

  • Explain the roles of browsers and servers
  • Break down the parts of a URL
  • Understand how DNS translates domain names to IP addresses
  • Describe the HTTP request/response cycle
  • Read and interpret common HTTP status codes
  • Use Chrome DevTools to inspect network traffic

πŸ”— Anatomy of a URL

A URL (Uniform Resource Locator) is the address of a resource on the web. Let's break one down:

https://www.example.com:443/products/shoes?color=red&size=42#reviews
Protocol https://
Domain www.example.com
Port :443
Path /products/shoes
Query ?color=red&size=42
Fragment #reviews
Part Example Purpose
Protocol https:// The "language" for communication. HTTPS = encrypted.
Domain www.example.com Human-readable name for the server.
Port :443 Door number on the server. 80 = HTTP, 443 = HTTPS.
Path /products/shoes Location of the resource on the server.
Query ?color=red Extra parameters (filters, search terms, etc.).
Fragment #reviews Jumps to a specific section on the page.
πŸ’‘
Good to know: The port is usually hidden β€” browsers use 80 for HTTP and 443 for HTTPS by default. The fragment (#) is never sent to the server β€” it's handled entirely by the browser.

πŸ–₯️ Client & Server Model

The web is built on a simple idea: a client (your browser) asks for something, and a server (a computer somewhere) sends it back.

Client–Server Communication

πŸ’»
Client (Browser)
Chrome, Firefox, Safari…
Sends requests, renders HTML/CSS
HTTP Request
β†’
←
HTTP Response
πŸ–₯️
Server
Stores files & data
Processes requests, sends responses

🌐 What the Browser Does

  • Sends HTTP requests to servers
  • Receives HTML, CSS, JS, images
  • Parses HTML into a DOM tree
  • Applies CSS styles
  • Executes JavaScript
  • Renders the final visual page

πŸ–₯️ What the Server Does

  • Listens for incoming requests
  • Finds the requested resource
  • Runs server-side code (if needed)
  • Queries databases
  • Sends back the response (HTML, JSON…)
  • Includes a status code (200, 404…)

πŸ” DNS: The Web's Phone Book

Computers communicate using IP addresses (like 93.184.216.34). But humans prefer names like example.com. DNS (Domain Name System) is the translator between the two.

DNS Resolution Steps

1
πŸ’»
Browser checks its local cache
2
πŸ–₯️
Asks the OS resolver
3
🏒
Queries the ISP's DNS server
4
🌍
Walks up to root β†’ TLD β†’ authoritative servers
βœ“
πŸ“¬
IP address 93.184.216.34 returned!
πŸ“
Analogy: DNS is like a phone book. You look up "Pizza Palace" (domain name) and get their phone number (IP address). Then you can call them (connect to the server).

πŸ“‘ HTTP: The Language of the Web

HTTP (HyperText Transfer Protocol) is the set of rules browsers and servers use to communicate. Every web page you visit involves at least one HTTP request and response.

πŸ“€ HTTP Request (what the browser sends)

Method GET
URL /products/shoes
Host www.example.com
Accept text/html
User-Agent Chrome/120.0

πŸ“₯ HTTP Response (what the server sends back)

Status 200 OK
Content-Type text/html
Content-Length 4523
Body <!DOCTYPE html><html>...</html>

Common HTTP Methods

GET Retrieve data (load a page)
POST Send data (submit a form)
PUT Update existing data
DELETE Remove data
πŸ’‘
HTTPS = HTTP + encryption (TLS/SSL). The padlock icon πŸ”’ in your browser's address bar means the connection is encrypted. Always prefer HTTPS.

πŸ“Š HTTP Status Codes

Every HTTP response includes a status code β€” a 3-digit number telling the browser what happened. They're grouped by their first digit:

1xx β€” Informational

100 Continue

2xx β€” Success βœ…

200 OK β€” everything worked
201 Created β€” new resource made

3xx β€” Redirection β†ͺ️

301 Moved Permanently
304 Not Modified (use cache)

4xx β€” Client Error ❌

400 Bad Request
403 Forbidden
404 Not Found β€” the classic!

5xx β€” Server Error πŸ’₯

500 Internal Server Error
503 Service Unavailable
⚠️
Quick memory trick: 2xx = 😊 success, 3xx = πŸ”€ redirect, 4xx = 🀦 you messed up, 5xx = πŸ”₯ server messed up.

πŸ› οΈ Chrome DevTools: Your X-Ray Vision

Chrome DevTools (and similar tools in Firefox/Safari) let you see everything happening under the hood. As a web developer, you'll use them constantly.

⌨️
How to open DevTools: Press F12 or Ctrl+Shift+I (Windows/Linux) or Cmd+Option+I (Mac). You can also right-click any element and choose "Inspect".

Key DevTools Tabs

πŸ”

Elements

Inspect and edit the live HTML & CSS of any page. See the DOM tree, modify styles in real-time, and debug layout issues.

πŸ“‘

Network

See every HTTP request the browser makes β€” HTML, CSS, JS, images, API calls. Inspect headers, status codes, and response times.

πŸ–₯️

Console

Run JavaScript directly, see errors and warnings, and log messages from your code. Your debugging best friend.

πŸ“

Responsive Mode

Toggle device toolbar to test how your page looks on phones, tablets, and different screen sizes.

πŸš€ Try it yourself!

  1. Open DevTools right now (F12)
  2. Click the Network tab
  3. Reload this page (Ctrl+R)
  4. Watch all the HTTP requests appear! Click on any to see headers and response

πŸ“‹ Module Summary

πŸ”—
URL

The address to find any resource on the web (protocol + domain + path + query + fragment).

πŸ’»
Client (Browser)

Sends requests, receives HTML/CSS/JS, and renders the visual page you see.

πŸ–₯️
Server

Stores files and data, processes requests, and sends back responses.

πŸ”
DNS

Translates human-readable domain names into machine-readable IP addresses.

πŸ“‘
HTTP/HTTPS

The protocol for communication. Methods (GET, POST…) + Status codes (200, 404…).

πŸ› οΈ
DevTools

Your X-ray vision into any web page β€” inspect HTML, network traffic, and run JS.

Next Module β†’

Module 1: HTML Essentials

Now that you understand how the web works, it's time to write your first HTML page! Tags, elements, attributes, headings, paragraphs, links, images, and lists.

β†’