Beginner-Friendly Topic
Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!
Lesson 8 of 10
How Websites Work (Frontend vs Backend)
Before diving deeper into HTML, it is important to understand the bigger picture of how websites actually work. When you type a URL into your browser and press Enter, a complex but elegant process happens in milliseconds - involving DNS servers, HTTP requests, servers, and browsers. Understanding this process helps you appreciate where HTML fits in the web development stack and what happens to your code once a user visits your page. This topic covers the frontend vs backend split, the client-server model, and the role HTML plays in delivering web content to users around the world.
What Happens When You Visit a Website
Here is the step-by-step journey of what happens when you type a URL like https://www.google.com into your browser:
- 1DNS Lookup: Your browser asks a DNS (Domain Name System) server to translate 'www.google.com' into an IP address (like 142.250.190.4). DNS is like the phonebook of the internet - it converts human-readable names to computer-readable addresses.
- 2TCP Connection: Your browser establishes a connection with the server at that IP address using TCP (Transmission Control Protocol). If the site uses HTTPS (which most do), there is also a TLS handshake for encryption.
- 3HTTP Request: Your browser sends an HTTP (HyperText Transfer Protocol) request to the server saying: 'Please send me the web page at this URL.'
- 4Server Processing: The server receives the request, processes it (possibly querying a database, running server-side code), and prepares the response.
- 5HTTP Response: The server sends back an HTTP response containing the HTML file, along with a status code (200 = success, 404 = not found, 500 = server error).
- 6Browser Rendering: Your browser receives the HTML, parses it, downloads any referenced CSS, JavaScript, and images, and renders (draws) the page on your screen.
This entire process typically takes less than a second!
Browsers request HTML from servers and render the received markup
Frontend vs Backend
- FRONTEND (Client-Side) - Everything that runs IN THE BROWSER on the user's device. This includes HTML (structure), CSS (styling), and JavaScript (interactivity). The user can see and interact with frontend code.
- BACKEND (Server-Side) - Everything that runs ON THE SERVER. This includes server languages (Node.js, Python, PHP, Java, Ruby), databases (MySQL, PostgreSQL, MongoDB), and server logic (authentication, data processing). The user never sees backend code.
- HTML is a FRONTEND technology - your HTML files are downloaded by the browser and rendered directly on the user's screen.
- The browser is the CLIENT - it sends requests to servers and displays the responses to the user.
- The server is the BACKEND - it receives requests, processes them, and sends back HTML, CSS, JS, and data.
- APIs (Application Programming Interfaces) - The bridge between frontend and backend. The frontend sends requests to API endpoints, and the backend responds with data (usually in JSON format).
- Full-Stack Development - Working on both frontend AND backend. Full-stack developers can build complete web applications from end to end.
- Static websites - Only HTML, CSS, and JS files. No backend processing. Fast and cheap to host (GitHub Pages, Netlify).
- Dynamic websites - Backend generates HTML on each request. Content changes based on the user, database, or other factors (WordPress, social media sites).
The Web Stack Visualized
<!-- The web development stack -->
<!--
USER'S BROWSER (Frontend)
┌────────────────────────────┐
│ HTML → Structure │
│ CSS → Styling │
│ JS → Interactivity │
└────────────┬───────────────┘
│ HTTP Request / Response
┌────────────┴───────────────┐
│ SERVER (Backend) │
│ Node.js / Python / PHP │
│ Database (MySQL/MongoDB) │
│ Authentication / APIs │
└────────────────────────────┘
-->
<!-- You can build a static site with just HTML! -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Static Website</title>
<style>
body { font-family: Arial; max-width: 600px; margin: 40px auto; }
.frontend { background: #e8f5e9; padding: 15px; border-radius: 8px; }
.backend { background: #fce4ec; padding: 15px; border-radius: 8px; margin-top: 10px; }
</style>
</head>
<body>
<h1>Frontend vs Backend</h1>
<div class="frontend">
<h3>🖥️ Frontend (you see this)</h3>
<p>HTML + CSS + JavaScript</p>
<p>Runs in your browser</p>
</div>
<div class="backend">
<h3>⚙️ Backend (you don't see this)</h3>
<p>Server code + Database</p>
<p>Runs on a remote server</p>
</div>
</body>
</html>Quick Quiz
Key Takeaways
- Before diving deeper into HTML, it is important to understand the bigger picture of how websites actually work.
- FRONTEND (Client-Side) - Everything that runs IN THE BROWSER on the user's device. This includes HTML (structure), CSS (styling), and JavaScript (interactivity). The user can see and interact with frontend code.
- BACKEND (Server-Side) - Everything that runs ON THE SERVER. This includes server languages (Node.js, Python, PHP, Java, Ruby), databases (MySQL, PostgreSQL, MongoDB), and server logic (authentication, data processing). The user never sees backend code.
- HTML is a FRONTEND technology - your HTML files are downloaded by the browser and rendered directly on the user's screen.
Finished this lesson?