From Zero to Deploy · Module 4 · Lesson 4.1
4.1 How a page is made
What happens when you open a site, how HTML, CSS, and JavaScript come together, and why some pages only work through a local server.
Every project in this course is a web page
The 3D game, the map app, the AI app: they’re all pages that open in a browser. So far you’ve written JavaScript that talks to the console. In this module you’ll see the whole page: what it’s made of, how the browser puts it together, and the tools for looking inside it. That’s what you need to follow, and check, what the AI builds in the big projects.
What happens when you open a site
Typing an address and pressing Enter starts a short conversation between your browser and a server, which is just a computer that answers requests by sending files. Put the steps in order:
Big sites use servers in data centers. While you’re building, your own computer can play that role, as you’ll see at the end of this lesson.
Three files, three jobs
A simple site is usually three files in the same folder:
| File | Its job | In a house, it would be |
|---|---|---|
index.html |
What’s on the page: headings, text, buttons | The walls and rooms |
style.css |
How it looks: colors, sizes, fonts, spacing | The paint and furniture |
script.js |
What it does: clicks, calculations, changes | The electricity |
The HTML connects the other two with two lines:
<link rel="stylesheet" href="style.css"> <!-- inside <head> -->
<script src="script.js"></script> <!-- at the end of <body> -->
href and src are addresses. Here they’re just a file name, so the browser looks for the file in the same folder as index.html.
In the example below, each tab is one of the three files (the playground connects them for you). Click the button, then change things:
Challenges:
- In the CSS tab, change the page background: replace
#fdf6ecwith#e8f4ef. - In the HTML tab, add a paragraph under the heading with your favorite cafe.
- In the JavaScript tab, add a fourth cafe to the list and click the button a few times.
Notice that each file changed only its own part: the content, the look, or the behavior. When you ask the AI for a change, it helps to know which of the three files it belongs in.
The style that didn’t load
Opening your project: a file or a server?
There are two ways to open index.html on your computer:
- Double-click the file. The address starts with
file://. That works for simple pages like the one above. - Through a local server. The address looks like
http://localhost:3000. Your computer acts as the server, and the page behaves the way it will on the internet.
For security, browsers limit what a page opened as a file can do. JavaScript modules (import, which three.js uses), fetching data with fetch, and some browser features don’t work from file://. The symptom is a blank page and a red error in the console that mentions CORS. When that happens, it isn’t your code: you need a local server.
The easiest way to start one is to ask Claude Code, inside the project folder:
Start a simple local server for this folder and tell me the address to open.
It will pick a tool your computer already has (for example npx serve or python3 -m http.server) and give you an address like http://localhost:3000. Open it in the browser. The server keeps running in that terminal, so leave it open while you work. To stop it, press Ctrl + C.
If your computer has none of those tools yet, there’s an option with nothing to install on the command line: in VS Code, add the Live Server extension, open the project folder, and click Go Live at the bottom of the window. And from the Data from the internet module on, once you’ve installed Node, npx serve always works.
Now on your machine
Create a folder for this module’s project and ask Claude Code for the three files:
In a new folder called my-cafes, create index.html, style.css, and script.js for a simple page called "My favorite cafes": a heading, a short intro paragraph, and a button that shows a random cafe from a list of three. Connect the CSS and JS files in the HTML. Don't use any libraries.
Then:
- Open
index.htmlwith a double-click and click the button. - Optional, for now: ask Claude to start a local server (or use Live Server), open the address, and click the button again.
Both work, because this page doesn’t use modules or fetch. If the server doesn’t work on your computer yet, that’s fine: this module’s project only needs the double-click. You’ll improve this page over the next lessons, and in the last one it becomes your module project.
Mark it complete to track your progress.
You've reached the end of the free lessons
The rest of the course, with the 3D game, the map app, the AI app, and your portfolio, is part of the full course.
See the full courseWant to know when the full course opens?
One email a week with a new lesson, a project, and a tip. No spam, unsubscribe anytime.