Module 1 · Lesson
Diagram of a web request: 1) the browser asks DNS for the IP address of harborlanebakery.com, 2) sends GET /menu.html to the web server, 3) the server replies 200 OK with HTML, CSS and JavaScript, 4) the browser draws the page

Time: about 4 hours. Course outcomes: 1, 6.

By the end of this module, you will be able to:

  • Explain what happens between typing a web address and seeing a page.

  • Name the parts of a URL.

  • Describe the roles of HTML, CSS and JavaScript.

  • Set up a project folder in Visual Studio Code and open your first page in a browser.

  • Use the browser's developer tools to inspect a page.

1.1 What happens when you visit a website

Every website involves two computers. Your device runs a client, usually a web browser such as Chrome, Firefox, Edge or Safari. Somewhere else, a server stores the website's files and sends them when asked.

When you type https://www.example.com/about and press Enter, four things happen in under a second:

  1. Finding the server. Your browser asks the Domain Name System (DNS), the internet's address book, for the numeric IP address that belongs to www.example.com.

  2. Asking for the page. The browser sends an HTTP request to that address: in effect, "Please send me the page at /about."

  3. Getting a response. The server sends back an HTTP response containing a status code and the page's files. Status 200 means OK; 404 means the page was not found; 500 means something broke on the server.

  4. Drawing the page. The browser reads the HTML, downloads any CSS, images and JavaScript it references, and renders the page on your screen.

The s in https means the connection is encrypted, so others on the network cannot read or change what is sent. Every professional website today should use HTTPS.

1.2 Reading a URL

Take https://www.harborlanebakery.com/menu.html?day=friday#cakes:

PartExampleWhat it does
SchemehttpsThe protocol used to communicate
Domainwww.harborlanebakery.comThe website's name, translated to an IP address by DNS
Path/menu.htmlWhich file or page on the server
Query?day=fridayExtra information sent to the server
Fragment#cakesA spot on the page to jump to
Diagram of the URL https://www.harborlanebakery.com/menu.html?day=friday#cakes split into scheme, domain, path, query and fragment, with what each part means
Figure 1.1 The five parts of a URL. Only the scheme and domain are required.

1.3 The three languages of the web

A useful way to think about a web page is a house:

  • HTML (HyperText Markup Language) is the structure: walls, rooms and doors. It says "this is a heading," "this is a list," "this is a link."

  • CSS (Cascading Style Sheets) is the decoration: paint, furniture and lighting. It controls colors, fonts, spacing and layout.

  • JavaScript is the electricity and plumbing: it makes things happen when people interact, such as opening a menu or checking a form.

You will learn them in that order, because each builds on the one before.

1.4 Setting up your toolkit

You need only free tools:

  • A browser. Chrome or Firefox is recommended because their developer tools are excellent.

  • Visual Studio Code (VS Code). A free code editor from Microsoft, available for Windows, Mac and Linux at code.visualstudio.com.

  • The Live Server extension for VS Code (recommended). It opens your page through a small local web server and refreshes it automatically when you save. Install it from the Extensions panel in VS Code.

Organizing files. Create a folder called harbor-lane-bakery in your Documents folder. Inside it, every page will be its own .html file. Two rules save a lot of trouble later:

  • Use lowercase letters and hyphens in file names, with no spaces: about-us.html, not About Us.html.

  • Name your home page index.html. Web servers open this file automatically when someone visits the site's main address.

1.5 Your first web page

Open the folder in VS Code (File > Open Folder), create a new file named index.html, and type:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Harbor Lane Bakery</title>
  </head>
  <body>
    <h1>Hello, world!</h1>
    <p>Fresh bread every morning in Warwick, Rhode Island.</p>
  </body>
</html>

Save the file, then right-click it in VS Code and choose Open with Live Server. (Double-clicking the file in your file explorer also works, but then the browser reads it straight from your disk instead of from a server.) You have just built a web page.

What each line does:

  • <!DOCTYPE html> tells the browser this is a modern HTML document.

  • <html lang="en"> wraps the whole page and declares its language, which helps screen readers and search engines.

  • <head> holds information about the page: the character set, the viewport setting for mobile devices, and the title shown on the browser tab.

  • <body> holds everything visitors see.

1.6 Developer tools: your best friend

Every major browser includes developer tools. Right-click anywhere on a page and choose Inspect (or press F12 on Windows, Cmd+Option+I on Mac). You will use three panels constantly:

  • Elements shows the page's HTML and the CSS applied to each element. You can edit both live to test ideas; changes disappear when you refresh.

  • Console shows error messages and lets you run JavaScript.

  • Network shows every file the browser downloaded, with its status code.

Professional developers spend much of their day in these panels. Get comfortable with them now.

Key terms: client, server, DNS, HTTP request and response, status code, HTTPS, URL, HTML, CSS, JavaScript, developer tools.