What Is a Website? Your First Web Page
Before we write code, let us understand what a web page really is. It is just a text file.
A web page is a text file
Every web page you open is a text file. The file name ends with .html. Your browser (Chrome, Firefox, Edge, Safari) reads this file and shows it as a nice page.
Three languages make most websites:
| Language | Its job | Think of it like |
|---|---|---|
| HTML | The content and structure: headings, text, images, links | The walls and rooms of a house |
| CSS | The look: colours, fonts, spacing, layout | The paint and furniture |
| JavaScript | Actions: menus that open, forms that check data | The electricity and switches |
This course teaches HTML and CSS. You can learn JavaScript after this.
How a website reaches your screen
When you type an address like example.com and press Enter, four things happen in less than a second:
- Your browser asks for the address. A system called DNS works like a phone book. It turns the name
example.cominto the number of the computer that stores the website. - The browser contacts that computer. It is called a server. A server is a computer that is always on and always connected to the internet.
- The server sends back files. First the HTML file, then the CSS files and images the HTML asks for.
- The browser draws the page. It reads the HTML, applies the CSS, and shows the result.
Renting space on a server is called hosting. In the last chapter you will put your own files on a free host. Until then, your own computer is enough, because the browser can open HTML files straight from your folders.
Tools you need (all free)
- A code editor. We suggest Visual Studio Code. It is free and works on Windows, Mac and Linux. Notepad also works, but it gives no help.
- A web browser. Chrome or Firefox is best because they have good developer tools.
That is all. No internet server, no payment, no installation of big software.
Set up VS Code in 5 minutes
VS Code works fine as soon as you install it. These small changes make learning much easier:
- Turn on Auto Save. Click File and tick Auto Save. Now you never forget to save before you reload the browser.
- Install the Live Server extension. Click the Extensions icon on the left (four small squares), search for "Live Server" and install it. Right-click your HTML file and choose Open with Live Server. The browser now reloads by itself every time you save.
- Install Prettier. Search for "Prettier" in Extensions. It tidies your code spacing for you, so your files stay easy to read.
! in an empty .html file and press Tab. VS Code writes the full page structure for you.Make your first web page
.html file is just text. The browser turns it into a page.- Make a new folder on your computer. Name it
my-website. - Open VS Code. Click File → Open Folder and pick
my-website. - Make a new file and save it as
index.html. - Type this code into the file and save it:
<!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.</p>
</body>
</html>This is my first web page.
Now double-click index.html in your folder. It opens in your browser. That is your first web page.
index.html first. So the home page of almost every website is called index.html.Good file and folder names
Servers on the internet are stricter than your laptop. A name that works on Windows can break online. Follow these rules from day one:
- Use small letters only:
about.html, notAbout.html. - Use dashes instead of spaces:
my-photos.html, notmy photos.html. - Use only letters, numbers and dashes. No
&,#,?or brackets. - Keep names short and clear. Google reads file names too, so
css-grid-guide.htmlis better thanpage7.html.
index.html.txt. In File Explorer, click View and turn on File name extensions to see the real name.Look inside any website
Open any website, right-click on it and choose Inspect. A panel opens. This is the Developer Tools panel. Here you can see the HTML and CSS of the page. You can even change them for fun (the change goes away when you reload). It is a good way to learn how other sites are built.
Common first-day problems
| What you see | Why it happens | Fix |
|---|---|---|
| The browser shows your code as plain text | The file is not really .html | Turn on file extensions and rename it |
| Your change does not appear | The file was not saved, or the page was not reloaded | Save, then press Ctrl + R (or use Live Server) |
| Strange symbols like é instead of é | The page does not say which character set it uses | Keep <meta charset="UTF-8"> in the head |
| Nothing shows at all | Text was written outside <body> or a tag is broken | Check that every tag is opened and closed |
What comes next
You now know what a website is, how it reaches the screen, and how to make and open an HTML file. In the next chapter you will learn the most common HTML tags. By the end of chapter 3 you will have a small website with several pages linked together.
Practice time
- Change the text inside
<h1>to your own name. Save and reload the browser. - Add a second
<p>line that says what you want to build. - Open your favourite website and use Inspect to find its main heading.
- Install Live Server and open your page with it. Change the text and watch it update.
- Rename a file using the rules in this chapter, then check it still opens.
Quick summary
- A web page is a text file that ends with
.html. - HTML = structure, CSS = look, JavaScript = actions.
- You only need a free code editor and a browser.