Chapter 1 of 15

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 browser windows: plain HTML page, the same page styled with CSS, and with a JavaScript popup
HTML builds the page. CSS makes it look good. JavaScript makes it do things.

Three languages make most websites:

LanguageIts jobThink of it like
HTMLThe content and structure: headings, text, images, linksThe walls and rooms of a house
CSSThe look: colours, fonts, spacing, layoutThe paint and furniture
JavaScriptActions: menus that open, forms that check dataThe 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:

  1. Your browser asks for the address. A system called DNS works like a phone book. It turns the name example.com into the number of the computer that stores the website.
  2. 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.
  3. The server sends back files. First the HTML file, then the CSS files and images the HTML asks for.
  4. 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:

  1. Turn on Auto Save. Click File and tick Auto Save. Now you never forget to save before you reload the browser.
  2. 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.
  3. Install Prettier. Search for "Prettier" in Extensions. It tidies your code spacing for you, so your files stay easy to read.
Shortcut to rememberType ! in an empty .html file and press Tab. VS Code writes the full page structure for you.

Make your first web page

An index.html file goes into the browser, which shows a page saying Hello, world
Your .html file is just text. The browser turns it into a page.
  1. Make a new folder on your computer. Name it my-website.
  2. Open VS Code. Click File → Open Folder and pick my-website.
  3. Make a new file and save it as index.html.
  4. Type this code into the file and save it:
HTML
<!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>
Result in the browser
Hello, world!

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.

Why the name index.html?When someone visits a folder on a website, the server looks for 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, not About.html.
  • Use dashes instead of spaces: my-photos.html, not my 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.html is better than page7.html.
Windows hides file endingsIf your file opens in Notepad instead of the browser, it may really be called 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.

A web page on the left and the developer tools panel with code on the right
Developer Tools show the HTML and CSS of any page.

Common first-day problems

What you seeWhy it happensFix
The browser shows your code as plain textThe file is not really .htmlTurn on file extensions and rename it
Your change does not appearThe file was not saved, or the page was not reloadedSave, then press Ctrl + R (or use Live Server)
Strange symbols like é instead of éThe page does not say which character set it usesKeep <meta charset="UTF-8"> in the head
Nothing shows at allText was written outside <body> or a tag is brokenCheck 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

  1. Change the text inside <h1> to your own name. Save and reload the browser.
  2. Add a second <p> line that says what you want to build.
  3. Open your favourite website and use Inspect to find its main heading.
  4. Install Live Server and open your page with it. Change the text and watch it update.
  5. 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.