Phase 1: Web Fundamentals 25 min comprehensive study⭐ High Priority Foundation

How the Web Works: A Beginner's Guide

Have you ever wondered what actually happens when you type google.com into your browser and press Enter? In under half a second, signals travel across undersea cables, query worldwide address directories, negotiate cryptographic encryption, process backend databases, and assemble millions of visual pixels on your screen. This comprehensive guide walks you through every single step from absolute scratch.

INTRO

Introduction: The Architecture Behind the Screen

Every single day, billions of people around the globe pick up smartphones, open laptops, click links, watch videos, buy products, and search for information online. To most users, this process feels instantaneous and magical: you tap a link, and a rich interactive interface appears out of thin air.

However, behind that clean screen lies one of the most astonishing engineering achievements in human history: a distributed worldwide network of computers communicating through standardized protocols, undersea fiber-optic cables, cryptographic handshakes, and browser rendering engines.

Why learn this first? Before writing a single line of HTML, CSS, JavaScript, or backend code, understanding how the web works gives you an unbeatable mental model. When an image fails to load, an API call errors, or a page feels sluggish, you will immediately know which part of the pipeline to investigate!
01

1. What Is the Web?

The Web (short for the World Wide Web or WWW) is a global collection of digital documents, multimedia files, and web applications that are interconnected by hyperlinks and identified by URLs (Uniform Resource Locators).

Invented in 1989 by Sir Tim Berners-Lee at CERN, the Web was designed to allow scientists across universities to share research papers easily. Today, it has evolved into the primary medium for human knowledge, commerce, entertainment, and social connection.

Documents

HTML Pages

Text, headings, articles, and formatted structure that browsers read and display.

Connections

Hyperlinks

Clickable references that allow users to jump instantly from one document to another anywhere in the world.

Applications

Web Apps

Interactive software (like Figma, Gmail, Pathubs, Netflix) running directly inside browser tabs.

02

2. Internet vs World Wide Web

One of the most common beginner confusions is using the words "Internet" and "Web" interchangeably. They are not the same thing:

Physical Network

The Internet (The Roads)

The massive global network of physical hardware — undersea cables, routers, satellites, fiber optics, and data centers connecting billions of computing devices together.

Software Service

The Web (The Cars & Cargo)

A software application/service that runs on top of the Internet infrastructure to serve web pages using HTTP/HTTPS.

Real-World Analogy: Think of the Internet as the global highway system of roads, bridges, and tunnels. The World Wide Web is the traffic of delivery trucks carrying web pages. Other vehicles using the same roads include Email (SMTP), File Sharing (FTP), Online Gaming, and Voice Calls (VoIP).
03

3. How Do Websites Actually Work?

At its core, every single website on earth operates on a fundamental architecture called the Client-Server Model:

  • 1. The Client (You): Makes a request for a web page by typing a URL or clicking a link.
  • 2. The Network: Transmits your request across the Internet to the correct destination machine.
  • 3. The Server (Host): Receives your request, finds or generates the files, and sends a response back.
  • 4. The Browser: Interprets the returned response and renders it into a visual, clickable page.
Visual Diagram: The Core Client-Server Interaction
💻
Client (Browser)
Your Laptop / Phone
1. HTTP Request ➔─────────►2. HTTP Response ◀
🏢
Web Server
Data Center (24/7)
Query Data ➔─────────►Return Records ◀
🗄️
Database
Persistent Storage
04

4. What Happens When You Enter a URL?

When you type an address like https://pathubs.com into your browser and press Enter, your computer executes a synchronized sequence of 5 high-level milestones:

Step 1: Address Resolution

The browser finds the server's physical IP address via DNS lookup.

Step 2: Secure Connection

Browser establishes a TCP handshake and negotiates TLS encryption keys.

Step 3: Sending Request

Browser transmits an HTTP GET request asking for the webpage document.

Step 4: Server Processing & Response

Server prepares HTML, CSS, JavaScript files and streams them back.

05

5. Understanding the Client and Server

The web divides computing duties between two distinct roles:

📱 The Client

The end-user device and software. It is responsible for accepting user input, sending requests, and displaying graphical results. Examples: Google Chrome, iPhone Safari, Spotify desktop app.

🖥️ The Server

A powerful computer located in a secure data center that stays powered on 24 hours a day, 7 days a week. It runs specialized server software that listens for incoming client requests and serves responses.

Restaurant Analogy: You are the Customer (Client) looking at a menu. The waiter delivers your order to the Kitchen (Server). The chef cooks the meal and sends the prepared plate back to your table!
06

6. What Is a Web Browser?

A Web Browser is a specialized software application that knows how to fetch web resources from the Internet, interpret code (HTML, CSS, JavaScript), and draw interactive pixels on your monitor or phone screen.

Under the hood, every modern browser contains three critical engines:

1. Rendering Engine

Parses HTML and CSS to build the visual page layout (e.g. Blink in Chrome/Edge, Gecko in Firefox, WebKit in Safari).

2. JavaScript Engine

Executes JavaScript code at blazing speeds using Just-In-Time (JIT) compilation (e.g. V8 in Chrome, SpiderMonkey in Firefox).

3. Networking Layer

Handles DNS resolution, HTTP/HTTPS requests, caching, SSL security, and data streaming.

07

7. What Is a Web Server?

The term Web Server refers to two related concepts:

  • Hardware: A physical computer with high-performance CPU, massive RAM, and ultra-fast network connections sitting in a data center.
  • Software: A background program (such as Nginx, Apache, Node.js, or Caddy) that actively listens on network ports (port 80 for HTTP, port 443 for HTTPS) for incoming client requests.
08

8. What Is a Website?

A Website is a collection of publicly accessible, interlinked web pages and multimedia assets (images, videos, stylesheets, scripts) that share a single domain name (e.g., pathubs.com).

09

9. What Is a Web Page?

A Web Page is a single document within a website, uniquely identified by a specific URL path (e.g., pathubs.com/about or pathubs.com/explore).

When you navigate from the homepage to an article, you are loading a different web page belonging to the same parent website.

10

10. Understanding URLs (Uniform Resource Locators)

A URL is the address used to pinpoint any unique resource across the entire World Wide Web. Just like your postal mailing address contains a country, city, street, and house number, a URL has a strict anatomy:

https://www.pathubs.com:443/courses/web-dev?ref=google&sort=popular#curriculum
URL ComponentExample in URLPurpose & Explanation
Protocol (Scheme)https://Defines the communication rule. HTTPS ensures encrypted communication.
Subdomainwww. or api.An optional prefix used to organize separate sub-sections of a website.
Domain NamepathubsThe unique registered brand or project name.
Top-Level Domain (TLD).com or .orgThe domain category suffix (.com, .io, .dev, .in, .edu).
Port:443The specific virtual gate on the server. (Default: 80 for HTTP, 443 for HTTPS).
Path/courses/web-devThe exact file or resource route on the web server.
Query Parameters?ref=google&sort=popularKey-value data passed to the server for search, sorting, or analytics.
Anchor / Hash#curriculumJumps directly to an element with that ID on the page (handled client-side).
11

11. Domain Names and IP Addresses

Computers do not understand human words like "Pathubs" or "Google" when routing network packets. They use numerical IP (Internet Protocol) Addresses:

IPv4 (32-bit standard)

Four numbers separated by dots (e.g. 142.250.190.46). Provides ~4.3 billion unique addresses.

IPv6 (128-bit modern standard)

Eight hexadecimal groups separated by colons (e.g. 2607:f8b0:4005:805::200e). Provides 340 undecillion addresses.

Because humans cannot easily remember 32-digit strings for every website, we use human-friendly Domain Names (like pathubs.com) as aliases.

12

12. DNS: How Domain Names Find Servers

The Domain Name System (DNS) is the worldwide distributed directory that translates human domain names into numerical IP addresses:

Visual Diagram: The 4-Tier DNS Resolution Hierarchy
💻
1. Browser
"Who is pathubs.com?"
Query ➔────────►
📡
2. DNS Resolver
ISP or 1.1.1.1
Root (.) ➔────────►
🌐
3. TLD Server
.com Nameserver
Auth ➔────────►
🏛️
4. Authoritative
Returns: 104.21.45.12
13

13. HTTP and HTTPS: The Language of the Web

HTTP (HyperText Transfer Protocol) is the communication protocol governing how messages are formatted and transmitted across the web.

Insecure

HTTP (Plain Text)

Sends data in unencrypted text. Anyone snooping on your public Wi-Fi router can see your passwords, credit card numbers, and visited pages.

Secure 🔒

HTTPS (Encrypted with TLS/SSL)

Encrypts all communication end-to-end. Even if an attacker intercepts the data packets, they only see scrambled, unreadable cryptographic noise.

14

14. How a Browser Requests a Web Page

Once the IP address is known, the browser initiates a TCP 3-Way Handshake to ensure a reliable two-way connection:

  1. SYN (Synchronize): Browser sends: "Hello server, I want to connect."
  2. SYN-ACK: Server replies: "Hello client, I hear you! Let's connect."
  3. ACK (Acknowledge): Browser confirms: "Awesome, connection established!"

Immediately after TCP, the TLS Handshake runs to negotiate cryptographic encryption keys.

15

15. How a Server Responds

Upon receiving the HTTP request, the web server reads the headers, validates authentication cookies, runs application business logic, and prepares an HTTP Response.

The server packages the requested HTML content into data packets and transmits them back across the network to your IP address.

16

16. HTTP Request and Response Anatomy

Both HTTP Requests and HTTP Responses have a clear, standardized text structure:

Visual Diagram: HTTP Request vs HTTP Response Anatomy

📤 HTTP Request (From Client)

GET /explore HTTP/2
Host: pathubs.com
User-Agent: Chrome/122.0
Accept: text/html
Authorization: Bearer token123

📥 HTTP Response (From Server)

HTTP/2 200 OK
Content-Type: text/html
Cache-Control: max-age=3600

<!DOCTYPE html><html>...</html>
17

17. Understanding HTTP Methods (Verbs)

HTTP methods tell the server what action you want to perform:

MethodAction TypeSafe & Idempotent?Real-World Example
GETRead / Retrieve data✅ Safe (Read-only)Viewing a blog post or opening a profile page.
POSTCreate new data❌ Not IdempotentSubmitting a registration form, placing an e-commerce order.
PUTReplace existing data completely✅ IdempotentUploading a brand-new avatar to overwrite the old one.
PATCHPartially update data❌ Modifies fieldsChanging just your username without re-submitting your entire profile.
DELETERemove data✅ IdempotentDeleting a comment or removing an item from your cart.
18

18. HTTP Status Codes

The server responds with a 3-digit status code that informs the browser of the result:

2xx Success

200 OK / 201 Created

The request succeeded! The requested page or data is included in the response body.

3xx Redirection

301 Moved / 304 Not Modified

The page has moved to a new URL, or the cached copy in your browser is still fresh.

4xx Client Error

400 Bad Request / 401 Unauthorized / 404 Not Found

The problem was on the client side (e.g. wrong URL, missing password, forbidden access).

5xx Server Error

500 Internal Error / 502 Bad Gateway / 503 Unavailable

The server crashed, encountered a bug, or is overloaded with too much traffic.

LIVE INTERACTIVE LAB

The 10-Step Journey of a Web Request

Click any step below or press Auto-Play Journey to trace how your computer fetches, decrypts, processes, and renders a web page in milliseconds.

https://pathubs.com/explore

⌨️1. User Enters URL

Client Stage

You type "https://pathubs.com/explore" into your browser address bar and hit Enter.

The browser first breaks down the URL string into its core components: protocol (https), domain name (pathubs.com), and resource path (/explore). It checks its own internal browser cache to see if you have visited this page recently.

Live Data Packet / Execution Log:
INPUT: "https://pathubs.com/explore"
PROTOCOL: HTTPS (Port 443)
TARGET HOST: pathubs.com
PATH: /explore
Pro Tip for Developers: Modern browsers also check HSTS (HTTP Strict Transport Security) preload lists to ensure the connection is upgraded to HTTPS before sending any bytes over the network.
Step 1 of 10
19

19. What Happens Inside the Browser? The Critical Rendering Path

Once HTML bytes arrive in the browser, the Critical Rendering Path (CRP) begins:

  1. 1. DOM Construction: HTML tokens are converted into Document Object Model nodes.
  2. 2. CSSOM Construction: CSS stylesheets are parsed into the CSS Object Model.
  3. 3. Render Tree: DOM and CSSOM combine to identify only the visible elements.
  4. 4. Layout (Reflow): The browser computes exact pixel geometry (width, height, coordinates).
  5. 5. Paint (Rasterization): Pixels are filled with actual text, colors, shadows, and images.
  6. 6. Compositing: Layers are drawn onto the screen via GPU hardware acceleration.
20

20. HTML, CSS and JavaScript: The Holy Trinity

The Skeleton

HTML

Provides raw structure, content, headings, paragraphs, forms, and semantic meaning.

The Skin & Clothes

CSS

Controls typography, vibrant colors, flexbox/grid layouts, dark mode, and smooth animations.

The Brain & Muscles

JavaScript

Adds logic, handles button clicks, fetches API data in real-time, and makes pages alive.

21

21. How HTML Becomes a Web Page

HTML (HyperText Markup Language) uses nested tags to create a hierarchy of elements. When the browser parses:

<div class="card">
  <h1>Welcome to Pathubs</h1>
  <p>Learn tech roadmaps for free.</p>
</div>

It turns every tag into a node in the DOM Tree. Parent nodes contain child nodes, forming an organized in-memory model that browsers render and scripts manipulate.

22

22. How CSS Styles a Web Page

CSS (Cascading Style Sheets) attaches visual rules to HTML elements using selectors, properties, and values:

.card {
  background: #1e1b2e;
  border-radius: 16px;
  color: #ffffff;
}

CSS also uses Media Queries (e.g. @media (max-width: 768px)) to reshape the layout seamlessly between desktop monitors, tablets, and smartphones.

23

23. How JavaScript Makes a Web Page Interactive

Without JavaScript, a webpage is a static document. JavaScript listens for user events (clicks, keypresses, scroll position) and dynamically alters the DOM:

  • Opening dropdown menus and modal windows without refreshing the page.
  • Validating form fields (e.g. checking if an email is valid) before submitting.
  • Fetching fresh data from APIs in the background using fetch().
24

24. Static vs Dynamic Websites

Static Websites

Pre-built HTML, CSS, and image files stored on a server. Every visitor receives the exact same file. Super fast, simple, and cheap to host. Examples: Documentation sites, landing pages, personal portfolios.

Dynamic Websites

Pages built on-the-fly when requested. The server executes backend code, verifies user authentication, queries databases, and customizes content for that specific user. Examples: Instagram, YouTube, Netflix.

25

25. Frontend vs Backend

Web development is divided into two primary disciplines:

🎨 Frontend (Client-Side)

Everything that runs inside the user's browser. Focuses on UI/UX, responsiveness, layout, animations, accessibility, and state management. Technologies: HTML, CSS, JavaScript, React, Vue, Tailwind.

⚙️ Backend (Server-Side)

Everything that runs on the web server. Handles database operations, authentication, payments, data encryption, and business logic. Technologies: Node.js, Python, Java, Go, PostgreSQL, Redis.

26

26. APIs and How Websites Communicate

An API (Application Programming Interface) is a standardized contract that allows two software systems to communicate. In modern web development, the frontend talks to the backend by exchanging structured JSON (JavaScript Object Notation) data:

// GET /api/user/profile
{
  "id": 42,
  "name": "Sandeep",
  "completedRoadmaps": ["frontend-dev", "data-analytics"],
  "streakDays": 14
}
27

27. What Is a Database?

A Database is a specialized software system engineered to securely store, search, update, and manage persistent data (such as user passwords, orders, comments, and analytics).

Visual Diagram: Full-Stack Data Flow
📱
Frontend (React/UI)
User submits login
POST /api/login ➔────────►
⚙️
Backend (Node/Python)
Hashes password
SQL SELECT ➔────────►
🗄️
Database (Postgres)
Returns user row
28

28. The Complete Journey of a Web Request

Let's tie every single piece together into the ultimate 10-phase sequence:

  1. 1. Enter URL: User types https://pathubs.com into browser.
  2. 2. DNS Lookup: Browser resolves pathubs.com into IP address 104.21.45.12.
  3. 3. TCP & TLS Handshake: Secure encrypted socket connection is established.
  4. 4. HTTP GET Request: Browser transmits request headers asking for the HTML file.
  5. 5. Server Processing: Backend executes business logic and queries database.
  6. 6. HTTP 200 Response: Server streams back HTTP response with HTML body.
  7. 7. Subresource Fetching: Browser parses HTML and fetches linked CSS, JS, and image assets.
  8. 8. DOM & CSSOM Construction: Browser builds the Document and CSS Object Models.
  9. 9. Layout & Paint: Browser computes geometric coordinates and draws pixels to the screen.
  10. 10. JavaScript Execution: Event listeners are bound and the web page becomes interactive!
29

29. A Real-World Example: Opening a Website

Imagine you are on a 5G smartphone in Mumbai opening Pathubs. In less than 380 milliseconds:

  • 0ms – 40ms: DNS resolver in Mumbai returns Cloudflare Edge IP.
  • 40ms – 110ms: TLS 1.3 handshake completes over encrypted cellular antenna.
  • 110ms – 180ms: HTTP/2 GET request reaches Edge server; server returns cached HTML.
  • 180ms – 290ms: Browser streams CSS bundle and fonts; renders initial page skeleton.
  • 290ms – 380ms: JavaScript hydrates, button clicks activate, and you start learning!
30

30. Common Beginner Misconceptions

❌ "Websites are stored in the sky (the Cloud)."

Reality:The "Cloud" is just someone else's physical computer sitting in a climate-controlled data center with backup generators and fiber connections.

❌ "HTML and CSS are programming languages."

Reality: HTML is a markup language for content structure; CSS is a style sheet language for design. JavaScript is the programming language with loops, variables, and logic.

❌ "Once loaded, the website uses constant internet."

Reality: HTTP is stateless. After files are downloaded into browser memory, the connection closes until another link or API request is triggered.

❌ "Webpages are just large image files."

Reality:Webpages are live, selectable text documents and code scripts assembled in real-time by your device's GPU and CPU.

31

31. Key Concepts to Remember

TermOne-Sentence Definition
ClientYour device/browser requesting and rendering web resources.
ServerA remote computer hosting website files and processing backend requests 24/7.
IP AddressThe numerical identification number of a computer on the Internet.
DNSThe internet directory that translates domain names into numerical IP addresses.
HTTP / HTTPSThe communication protocol of the web; HTTPS provides TLS encryption.
DOMThe in-memory tree representation of HTML elements parsed by the browser.
APIA communication channel allowing frontend and backend to exchange structured data.
DatabaseA persistent storage engine for records, user accounts, and application data.
TEST YOUR KNOWLEDGE

How the Web Works Mastery Quiz

Test your understanding of DNS, Client-Server architecture, HTTP status codes, and browser rendering.

Question 1 of 10Score: 0 / 10

🌐 What is the fundamental difference between the Internet and the World Wide Web?

END

Conclusion & Next Steps

Congratulations! You now understand the complete anatomy of the modern web — from physical Internet cables and DNS lookups to HTTP handshakes, server processing, critical rendering paths, and database queries.

With this rock-solid mental foundation in place, you are ready to begin writing actual code! The next step in your developer journey is mastering HTML to structure your very own web pages.