Skip to content

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.

14 min read0/4 questions

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.

Loading one page
YouBrowserServertype a URL, press EnterGET /index.htmlGET /style.cssstyle.cssGET /app.jsapp.jsthe finished page

You give the browser an address, called a URL (Uniform Resource Locator).

1/8

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 it in order5 steps

Put the steps of loading a page in order.

  1. Tap the steps below in the right order.
Need a nudge? A hint shows where it starts.

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.

HTML & CSS
<style> .card { max-width: 320px; padding: 16px; border: 2px solid #222; border-radius: 12px; } h2 { margin-top: 0; color: #c2410c; }</style> <div class="card"> <h2>Pancakes</h2> <p>Fluffy pancakes in 20 minutes.</p> <button id="like">Like this recipe</button></div> <script> document.getElementById("like").addEventListener("click", () => { document.getElementById("like").textContent = "Liked!"; });</script>

Preview

Click the button to see JavaScript at work. Then try these, one at a time:

  • Change Pancakes to the name of your favourite food. That is editing HTML content.
  • Change #c2410c to blue. 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 the pairs0/4 matched

Match each task to the language that does it.

Choose an item, then its match on the other side.

From text to pixels

When the HTML arrives, the browser does not show it as text. It works through a few stages:

How the browser builds what you see
  1. Parse HTMLturn tags into a tree of elements (the DOM)
  2. Apply CSSwork out the styles for every element
  3. Layoutdecide the size and position of each box
  4. Paintfill in the pixels on screen

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.

1/4

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:

PanelWhat it showsTry this
Elements (Firefox: Inspector)The live HTML tree of the pageDouble-click some text and change it
Styles (inside Elements)The CSS rules applied to the selected elementUntick a rule to switch it off
ConsoleMessages and errors from JavaScript, plus a place to type JavaScriptType 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.

Quick check
A button on your page does nothing when clicked. Which devtools panel should you check first?
Need a nudge? A hint rules out a wrong answer.

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:

  1. Download VS Code from code.visualstudio.com and install it.
  2. Make a new folder somewhere easy to find, called my-site.
  3. In VS Code choose File > Open Folder and pick my-site.
  4. Create a new file and name it exactly index.html. The name index.html matters: web servers show it by default when someone visits a folder.
  5. Paste in the code below and save.
Your first project
  • 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:

HTML & CSS
<h1>Hello, web!</h1><p>I made this page myself.</p><p>My favourite food is <strong>pancakes</strong>.</p>

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.

Quick check
You double-click index.html and the address bar shows file:///Users/sam/my-site/index.html. What does that tell you?
Need a nudge? A hint rules out a wrong answer.

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.

Key terms
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.