You’ve almost certainly written some HTML already. Maybe you pasted a snippet into a template or nudged a layout until it looked right without knowing why it worked. This course is the first of seven on the HTML and CSS Foundations path, and it swaps that guesswork for a model of what the browser does with your markup.
You’ll learn it by building something real. Rosa coordinates the volunteers of the Elm Street Community Garden, and she wants a website to replace the paper notices pinned to the shed. In this lesson, you’ll set up the site’s folder, write its first page, and open it in the browser with the tools you’ll use throughout the course.
Get Your Tools Ready
Every web page you’ve ever visited is HTML underneath. CSS styles that structure, and JavaScript changes it. The browser uses HTML to tell screen readers what each part of the page is, and search engines read it to understand the page. That’s why getting the HTML right comes first and why Rosa’s pages will have no CSS yet. The browser’s plain default styles let you see that structure and look are separate.
This course assumes you can program in some language. You don’t need any JavaScript, and none appears here. However, HTML isn’t a programming language. It doesn’t run, and it doesn’t stop with an error when you get something wrong. The next lesson shows what the browser does instead.
You need two tools:
- A current version of Chrome or Edge: Every screenshot comes from Chrome, and Edge displays pages the same way.
- An editor with a live preview: The steps here use Visual Studio Code with Microsoft’s free Live Preview extension. Another editor with a preview server works too.
If you don’t have VS Code yet, install it from its website first. To install Live Preview, open VS Code’s Extensions view with Ctrl+Shift+X or Cmd+Shift+X on macOS, search for Live Preview, and click Install on the one published by Microsoft.
Work through each lesson with your page open beside it. Type the examples rather than pasting them, and change things to see what happens. Each section of the course ends with exercises, and the course ends with a project in which you build the garden’s three-page site.
Create the First Page
A website starts as a folder of files. Make a folder called garden/ wherever you keep your projects, open it in VS Code with File → Open Folder, and create a file called index.html inside it:
garden/
│
└── index.html
The name index.html matters. When someone asks for a folder, Live Preview’s server and many others send that folder’s index.html, so this file becomes the garden’s home page. Type this into it:
index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Elm Street Community Garden</title>
</head>
<body>
<main>
<h1>Elm Street Community Garden</h1>
<p>Volunteers grow vegetables here every season.</p>
</main>
</body>
</html>
A tag is a name in angle brackets, like <p> and </p>, which mark where a paragraph starts and ends. A start tag, an end tag, and everything between them make an element. Some elements, like <meta>, have only a start tag. The first line, <!doctype html>, is a declaration rather than a tag. It tells the browser this is modern HTML.
The <html> element contains the whole document. Its start tag also holds an attribute, lang="en". An attribute is a name and a value that add information to an element, and it’s always written in the element’s start tag.
Here, lang declares that the page is in English, which helps screen readers pronounce it. In <meta charset="utf-8">, the charset attribute specifies the file’s text encoding, UTF-8, so the browser reads every character as you typed it.
Everything inside <head> describes the page, such as the <title> that appears on the browser tab. Everything inside <body> is what appears in the window. There, <main> marks the page’s main content, so assistive technology can jump straight to it. It holds a main heading, <h1>, and a paragraph, <p>. You’ll write every line of this skeleton yourself and learn what each part does in a later lesson. For now, it gives you a working page to look at.
Save the file with Ctrl+S or Cmd+S on macOS. VS Code’s Explorer should show index.html inside garden, and the file’s tab loses the dot that marks unsaved changes.
Serve the Page and Inspect It
You could double-click index.html and the browser would open it from your disk, with an address starting file://. That works for this page, but a page opened this way doesn’t always behave like a real website. For example, a link starting with /, which you’ll meet later in the course, points at the top of your whole drive instead of the top of your site.
So this course serves its pages from a local server, which sends your files to the browser over http:// as a real website would. Every URL behaves the same for you as for visitors, and the page updates itself as you edit.
Live Preview provides that server. With index.html saved and open as the active tab in the editor, open the Command Palette with Ctrl+Shift+P or Cmd+Shift+P on macOS and run Live Preview: Show Preview (External Browser). Your page opens at an address like http://127.0.0.1:3000/index.html. If it opens in a browser other than Chrome or Edge, paste that address into Chrome or Edge.
You should see the heading and the paragraph in the browser’s default styles:

Try it: replace the paragraph with Volunteers grow vegetables and herbs here every season. in VS Code, and watch the page change. With Live Preview’s default settings, the page updates as you type, before you save. Save afterward anyway, so the file on disk matches what you see.
Here’s the page once the new paragraph is in:

If the preview stays blank or shows an error, the mentor can help you work out why. The button below opens a chat with your question already typed, so you can add what you see and talk it through:
The last tool is DevTools, the set of panels built into Chrome for looking inside a page. With your page open, right-click the heading and choose Inspect, or press F12, Ctrl+Shift+I, or Cmd+Option+I on macOS. The shortcuts open whichever panel you used last, so if another one appears, click the Elements tab.
The Elements panel shows the page’s elements nested inside each other. The Console tab next to it is where the browser reports messages and where you’ll sometimes type a one-line question about the page.
One element in the Elements panel isn’t yours. Expand <head>, and you’ll find a <script> element that Live Preview adds to every page it serves. It’s the code that reloads the page when you edit, and it never touches the file on your disk.
Here’s the panel with the heading selected and <head> expanded:

That <script> element is a first clue that the Elements panel isn’t showing your file, even though the two look a lot alike. In the next lesson, See How the Browser Reads HTML, you’ll find out what the browser built from it and what it does when your HTML has a mistake.