How websites work and your first web page
Learn what HTML and CSS do, set up a free code editor, and build and open your very first web page in a browser, step by step, on Windows, macOS or Linux.
🎯 By the end of this lesson you will be able to:
- Explain what a browser, a web server, HTML and CSS each do
- Set up a project folder and a code editor
- Write a complete HTML page, save it and open it in a browser
Outline
What you'll learn and why it matters
Every website you have ever visited, from a small blog to a big shopping site, is built on two languages: HTML for the content and CSS for the look. Learn these two and you can build your own pages, understand how the web works, and take your first step towards front-end, full-stack or UI design jobs.
By the end of this lesson you will have a real web page, written by you, open in your browser.
How a web page reaches your screen
When you visit a website, your browser (Chrome, Edge, Firefox or Safari) asks a web server (a computer that stores websites) for the page. The server sends back files, and the browser turns them into the page you see.
| Language | Its job | Think of it as |
|---|---|---|
| HTML (HyperText Markup Language) | The content and structure: headings, paragraphs, images, links | The walls and rooms of a house |
| CSS (Cascading Style Sheets) | The look: colours, fonts, spacing and layout | The paint, furniture and decoration |
| JavaScript | Behaviour: things that react when you click or type | The electricity and switches (a later course) |
Set up your tools (about 10 minutes)
You need two free things: a browser, which you already have, and a code editor, a text editor made for code. We use Visual Studio Code (VS Code), which is free and works on Windows, macOS and Linux.
- Go to
code.visualstudio.com, download VS Code for your computer and install it with the default options. - Create a folder for your work, for example
my-websiteinside your Documents folder. - Open VS Code, choose File → Open Folder…, and select
my-website. If VS Code asks whether you trust the authors of the files, choose Yes: it is your own folder. - In the Explorer panel on the left, point at the folder name and click the New File icon (a page with a plus sign). Type
index.htmland press Enter. VS Code creates the empty file in your folder and opens it.
Your first web page
Type this into index.html (typing is better than pasting while you learn, because you notice every detail), then save with Ctrl+S (Windows and Linux) or Cmd+S (Mac).
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My first page</title>
</head>
<body>
<h1>Hello, world!</h1>
<p>This is my first web page. I built it myself.</p>
</body>
</html>Browser preview
Now open it: find index.html in your folder and double-click it. It opens in your default browser and looks like the preview above. The title My first page appears on the browser tab, not on the page.
What each line does
| Line | What it means |
|---|---|
<!DOCTYPE html> | Tells the browser this is a modern HTML page. Always the first line. |
<html lang="en"> … </html> | Wraps the whole page. lang="en" says the page is in English, which helps screen readers and translation tools. |
<head> … </head> | Information about the page that is not shown on it. |
<meta charset="utf-8"> | Lets the page show every language's letters and symbols correctly, such as é, ñ, ₹ and emoji. |
<title> | The name on the browser tab and in search results. |
<body> … </body> | Everything visible on the page goes here. |
<h1> and <p> | A main heading and a paragraph. You will learn many more in the next lesson. |
The edit, save, refresh loop
This is how web developers work all day long:
- Change the code in your editor.
- Save the file (Ctrl+S or Cmd+S).
- Switch to the browser and refresh (F5, or Cmd+R on a Mac).
Try it now: change the heading to Hello from followed by your own name, save, and refresh. If nothing changes, you probably forgot to save: VS Code shows a dot on the file's tab when there are unsaved changes.
Practice
Guided exercise
A page about you
Make a second page called about.html in the same folder, with the tab title About me, a main heading with your name and one paragraph about yourself.
- In VS Code's Explorer panel, click the New File icon and name it
about.html. - Type the same skeleton as
index.html(or use the!shortcut). - Change the
<title>toAbout me. - Put your name in the
<h1>and a sentence about yourself in the<p>. - Save, then double-click the file to open it in your browser.
Show the solution
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>About me</title>
</head>
<body>
<h1>Asha Kumar</h1>
<p>I am learning to build websites so I can make a page for my family's bakery.</p>
</body>
</html>Browser preview
How to get there: Every page needs the same skeleton: doctype, html, head with a charset and title, and body. Only the title and the content inside body change from page to page.
Your turn
Two paragraphs and a fix
Add a second paragraph to about.html about a hobby. Then change the tab title to About Asha (use your name) and check the tab in the browser shows the new title.
Show the solution
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>About Asha</title>
</head>
<body>
<h1>Asha Kumar</h1>
<p>I am learning to build websites so I can make a page for my family's bakery.</p>
<p>In my free time I play badminton and grow tomatoes on my balcony.</p>
</body>
</html>Browser preview
How to get there: Each paragraph gets its own <p> … </p> pair inside body. The <title> lives in head, so it changes the tab, not the page itself. Remember to save and refresh.
Common mistakes
Saving as index.html.txt or in Rich Text format
You see: The browser shows your code as plain text, or the file opens in a text editor
Fix: Show file extensions and rename the file to end in .html. Use a code editor or plain-text mode.
Forgetting to save before refreshing
You see: Your change does not appear
Fix: Save first (Ctrl+S or Cmd+S), then refresh. Look for the unsaved-changes dot on the editor tab.
Putting visible content inside <head>
You see: Text you typed does not appear on the page
Fix: Everything people should see goes inside <body>.
Leaving out <meta charset="utf-8">
You see: Symbols like ₹, é or ’ show up as strange characters
Fix: Add the charset line as the first thing inside <head>.
Recap
- The browser asks a server for files; HTML gives the content and structure, CSS gives the look.
- A web page is a plain-text file ending in
.htmlthat a browser can open from your own folder. - Every page starts with the same skeleton: doctype,
html,head(charset, title) andbody. - Work in a loop: edit, save, refresh.
Key terms
- Browser
- The program that shows web pages, such as Chrome, Edge, Firefox or Safari.
- Web server
- A computer that stores websites and sends their files to browsers.
- HTML
- HyperText Markup Language: describes the content and structure of a page.
- CSS
- Cascading Style Sheets: describes how a page looks.
Check your understanding
Answer all 4 questions, then check your answers to see an explanation for each one.
1. Which language controls the colours, fonts and layout of a web page?
2. Where does the text inside `<title>` appear?
3. You changed your HTML, refreshed the browser, and nothing changed. What is the most likely reason?
4. Which part of the page skeleton holds everything visible on the page?
Mark this lesson complete
Finished this lesson?
When you have worked through the examples and exercises, mark it complete to save your progress.