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.

⏱ 20 min

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:

Put in order

From the address to the page

  1. 1The server answers with an HTML file
  2. 2The browser reads the HTML from top to bottom
  3. 3The browser asks the server for that address
  4. 4It finds the CSS and JavaScript files the HTML points to, and asks for them too
  5. 5It draws the page and runs the JavaScript
  6. 6You type the address (the URL) and press Enter

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:

Try it

My favorite cafes

Result

Challenges:

  1. In the CSS tab, change the page background: replace #fdf6ec with #e8f4ef.
  2. In the HTML tab, add a paragraph under the heading with your favorite cafe.
  3. 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

Find the bug

The page opens, but with no colors or fonts at all. Which line has the problem?

The project folder has three files: index.html, style.css, and script.js.

Click the line with the problem.

Opening your project: a file or a server?

There are two ways to open index.html on your computer:

  1. Double-click the file. The address starts with file://. That works for simple pages like the one above.
  2. 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.

Sort it

Where is this page coming from?

  • file:///Users/ana/Documents/my-cafes/index.html
  • http://localhost:3000
  • https://julianreyes.dev/skyrunner/
  • http://127.0.0.1:8080
  • https://ana.github.io/mini-ceu/

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:

  1. Open index.html with a double-click and click the button.
  2. 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.

Task

Practice

0 of 5 done

Checkpoint

Check what you learned

  1. Which file does the browser get first when you open a site?

  2. The page opens with no style at all, and nothing on the screen says why. What do you check first?

  3. Your 3D game shows a blank page, the console mentions CORS, and the address starts with file://. What do you do?

  4. What is localhost?

Finished the lesson?

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 course