Lesson 1 of 52HTML
How Web Pages Work
Follow a page from the address bar to your screen, meet HTML, CSS and JavaScript, and build your first page on your own computer.
Every website you have ever used, from a search engine to a recipe blog, is built from the same three ingredients: HTML, CSS and JavaScript. Your browser downloads them as plain text files and turns them into the colourful, clickable page you see. Once you know what happens in those few hundred milliseconds, the rest of this course makes sense: you will always know which file to open and which language to reach for. By the end of this lesson you will have made a real web page on your own computer and opened it in your browser.
What happens when you open a page
Say you type recipes.example.com into the address bar and press Enter. Two programs are involved. Your browser (Chrome, Firefox, Safari, Edge) is the client: the program that asks for things. Far away, a server is a computer whose job is to answer those requests by sending files back.
The conversation between them follows a set of rules called HTTP (HyperText Transfer Protocol). The browser sends a request ("please give me the page at /") and the server sends a response (a status like 200 OK plus the file itself). The first file is almost always an HTML file. As the browser reads it, it finds links to more files it needs, such as a stylesheet and a script, and asks for those too.
You give the browser an address, called a URL (Uniform Resource Locator).
A busy page might make dozens of these requests: one for each image, font, stylesheet and script. That is why heavy pages feel slow on a weak phone signal, and why later lessons care about image sizes and loading.
Put the steps of loading a page in order.
- Tap the steps below in the right order.
Three languages, three jobs
Think of a web page like a house.
- HTML (HyperText Markup Language) is the structure: the walls, rooms and doors. It says what each piece of content is: this is a heading, this is a paragraph, this is a link, this is an image.
- CSS (Cascading Style Sheets) is the decoration: paint, furniture and lighting. It says how things look: colours, fonts, spacing, and where things sit on the screen.
- JavaScript is the electricity and plumbing: it makes things happen. It reacts when you click, type or scroll, and can change the page while you are looking at it.
You can build a useful page with HTML alone. It will look plain, but it will work, and a screen reader (software that reads pages aloud for people who cannot see the screen) can understand it. CSS and JavaScript are layers you add on top.
Here is a tiny page that uses all three. The left side is the code, the right side is a live browser preview.
Preview
Click the button to see JavaScript at work. Then try these, one at a time:
- Change
Pancakesto the name of your favourite food. That is editing HTML content. - Change
#c2410ctoblue. That is CSS changing the look. - Change
"Liked!"to"Yum!"and click the button again. That is JavaScript changing behaviour.
The <style> and <script> sections live inside the HTML here to keep the example small. On real sites they usually sit in separate .css and .js files that the HTML links to, which is exactly what the browser was requesting in the diagram above.
Match each task to the language that does it.
From text to pixels
When the HTML arrives, the browser does not show it as text. It works through a few stages:
The browser reads the HTML and builds the DOM (Document Object Model): a tree of every element on the page, which JavaScript can later read and change.
You do not need to remember these stage names yet. The useful idea is that the browser builds a tree of elements from your HTML, and everything else (styles, layout, scripts) works on that tree.
Look inside any page with devtools
Every desktop browser has developer tools (devtools for short): a built-in panel that shows you the HTML, CSS and JavaScript behind any page. It is the single most useful tool in web development, and it is already installed.
To open it, right-click anything on a page and choose Inspect. Or press F12 (Windows and Linux) or Cmd + Option + I (Mac). Three panels matter most at the start:
| Panel | What it shows | Try this |
|---|---|---|
| Elements (Firefox: Inspector) | The live HTML tree of the page | Double-click some text and change it |
| Styles (inside Elements) | The CSS rules applied to the selected element | Untick a rule to switch it off |
| Console | Messages and errors from JavaScript, plus a place to type JavaScript | Type 1 + 1 and press Enter |
Try it right now on this page. Right-click this paragraph, choose Inspect, and double-click the text in the Elements panel to change it. Your edit only happens in your own browser and vanishes when you reload. You cannot break a website this way, so explore freely.
Make your first page on your computer
You can write HTML in any plain text editor, but a code editor makes it much easier. VS Code (Visual Studio Code) is free, popular and works on Windows, Mac and Linux. Setup takes a few minutes:
- Download VS Code from
code.visualstudio.comand install it. - Make a new folder somewhere easy to find, called
my-site. - In VS Code choose File > Open Folder and pick
my-site. - Create a new file and name it exactly
index.html. The nameindex.htmlmatters: web servers show it by default when someone visits a folder. - Paste in the code below and save.
- my-site/
- index.htmlthe home page
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My first page</title>
</head>
<body>
<h1>Hello, web!</h1>
<p>I made this page myself.</p>
</body>
</html>Now open the folder in your computer's file browser and double-click index.html. It opens in your browser, and the address bar shows something starting with file:// instead of https://. That means the browser is reading the file straight from your disk, with no server involved. Edit the text in VS Code, save, and reload the browser tab to see your change.
Two small extras make life nicer. In VS Code, type ! in an empty HTML file and press Tab: a feature called Emmet writes the whole page skeleton for you. And the Live Server extension (search for it in the Extensions panel) reloads the browser automatically every time you save.
Here is the same first page as a live editor, so you can play before setting anything up:
Preview
Try changing the heading to your own name, then add another line that starts with <p> and ends with </p>. You will learn exactly what those tags mean in the next lesson.
index.html and the address bar shows file:///Users/sam/my-site/index.html. What does that tell you?How this course is laid out
- HTML first: elements, text, images, forms, tables, accessibility, the head and SVG. This is the structure everything else hangs on.
- CSS foundations and Layout next: selectors, the box model, colour, type, then Flexbox, Grid, positioning and responsive design.
- Modern CSS and Accessibility in depth: variables, theming, motion, dialogs, CSS architecture, then WCAG, ARIA, focus and screen reader testing.
- Tailwind CSS and Tailwind in practice: the same ideas written as utility classes, up to design systems, React and team habits.
- Performance and tooling and Beyond the screen: page speed, DevTools, cross-browser fixes, print and HTML email.
- Project: a landing page, a portfolio and a Tailwind dashboard, built from scratch.
By the end you will be able to build a fast, accessible, responsive site from a blank folder and put it online. The course closes with a short wrap-up that ties it all together.
- browser
- The program (Chrome, Firefox, Safari, Edge) that requests web files and turns them into a page you can see and use.
- server
- A computer that answers requests by sending back files or data.
- HTTP
- The set of rules browsers and servers use to send requests and responses.
- URL
- A web address, such as https://example.com/recipes, that says where a resource lives.
- HTML, CSS, JavaScript
- The three languages of the web: structure and meaning, appearance and layout, and behaviour.
- DOM
- The tree of elements the browser builds from your HTML, which CSS styles and JavaScript can change.
- devtools
- Developer tools built into the browser for inspecting and experimenting with any page's HTML, CSS and JavaScript.