Skip to the workspace
Pebellslearn by building
Introduction  ›  Lesson

HTML — The Structure CSS Styles

HTML 12 minCSS reaches elements only through hooks the HTML provides: element names, classes, ids and their position in the document tree.

Set up CSS and run your first file

CSS styles an HTML document. Set up two neighboring files and make one visible style change; there is no separate CSS program to install.

Already set up? Continue to the lesson

New to coding? Meet the tools and find the terminal
Text editor
Saves the source as plain text with the correct extension.
Browser
Reads HTML and CSS, builds the page, and provides developer tools.
Developer tools
Inspect the actual elements and applied styles when a change is missing.

A terminal is a window for commands. Its shell interprets those commands. PATH is the list of folders the shell searches for programs. An editor extension adds editing help; it usually does not install the language itself.

In VS Code, open your project folder, then choose View → Terminal. Type at the cursor in the Terminal panel, not in Output, the source file, or the browser address bar. Our command blocks omit prompt symbols such as $ and >; do not add them.

Official VS Code screenshot: the Terminal tab is selected below the editor, with the PowerShell shell name at the right and a command prompt at the left.
Find the Terminal tab and shell name. Open full-size screenshot (new tab).

The dropdown next to the plus button selects a shell. Choose the shell named in your operating-system instructions below. Available choices depend on what you installed.

Official VS Code screenshot: the arrow beside the terminal plus button opens a list containing PowerShell, Command Prompt, Git Bash and Ubuntu WSL.
Official documentation screenshots by Microsoft, VS Code terminal guide, CC BY 3.0 US. Unmodified; your version may look different.

Choose a system to see its installation steps. A computer is needed for these local setup instructions.

Official documentation and illustrated guides

Instructions reviewed 2026-10-27. Use the linked installer page for current versions and supported operating systems.

Continue to the lesson

css / HTML — The Structure CSS Styles

Explore each scene at your own pace.

01 · The rule

The rule

HTML — The Structure CSS Styles

CSS reaches elements only through hooks the HTML provides: element names, classes, ids and their position in the document tree.

Inspect the element names, attributes and relationships that selectors can reach.

Imagine being asked to "make the prices green" on a café's website. Before you can write a single line of CSS, you need to know where the prices are, what they are called, and what they sit inside. CSS never invents elements. It dresses the ones HTML already built.

The rule

CSS can only style what the HTML has already named.

Every CSS rule starts by pointing at elements. It can point using three kinds of hook that live in the HTML:

  • the element name, such as h2 or p
  • a class, such as class="price"
  • an id, such as id="menu"

It can also use position in the tree: an element's parent, its children and its siblings. So the HTML is not just content; it is the map CSS reads.

Here is the page we will style for the whole course, the home page of a small café:

<body>
  <header id="top">
    <h1>Harbour Café</h1>
    <nav class="site-nav">
      <a href="#menu">Menu</a>
      <a href="#visit">Visit</a>
    </nav>
  </header>
  <main>
    <section id="menu">
      <h2>Today's menu</h2>
      <article class="dish">
        <h3>Masala omelette</h3>
        <p class="price">₹180</p>
        <p>Three eggs, green chilli and coriander.</p>
      </article>
      <article class="dish special">
        <h3>Mango lassi</h3>
        <p class="price">₹120</p>
        <p>Thick, cold and only in summer.</p>
      </article>
    </section>
    <section id="visit">
      <h2>Visit us</h2>
      <p>Open 8 am to 6 pm, every day.</p>
    </section>
  </main>
  <footer>
    <p>Harbour Café, Marine Drive</p>
  </footer>
</body>

Read it as a family tree. body has three children: header, main and footer. Each article is a child of section#menu and the parent of an h3 and two paragraphs.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.