In this video, you read Rosa’s home page the way the browser’s parser reads it. The parser follows HTML’s own rules, not the way your file looks:
- A slash closes nothing.
<div class="plot-map" />is only a start tag. The div stays open, and the paragraph, both headings and both events after it land inside, because a div, unlike a paragraph, may hold headings. It closes only when the parser reaches</main>. A div has no look of its own, so the page looks the same. Hover the div in the Elements panel, and its box covers everything down to the seed swap, so a style for that box would reach all of it. Write<div class="plot-map"></div>instead. - Only void elements stand alone. A void element can’t hold content, so it has no end tag. The common ones are
<meta>,<link>,<img>,<br>,<hr>and<input>. A slash on one does nothing either, and the Elements panel shows<meta charset="utf-8" />as<meta charset="utf-8">. Leave the slash off, so you won’t expect it to close a div. Give every other element its end tag, so the tree is the one you meant. HTML lets you omit a few end tags, like a paragraph’s (<p>First<p>Secondbuilds two paragraphs), but this course always writes them. - Whitespace shows as one space. The tree keeps your text’s line breaks and indentation, but by default the browser displays each run of spaces, tabs and line breaks as one space, and none at the start or end of the text. So the work day paragraph, with its last sentence on its own indented line, shows its two lines joined by one space.
- A
<in text starts a tag when a letter follows it. Rosa’s address in angle brackets vanished from the page, because the parser read it as an element. Write the character reference<for<. A>on its own starts nothing, but>keeps the pair matching. An ampersand starts every reference, so you write one in your text as&.
Here’s the <main> of index.html at the end of the video:
index.html
<main>
<h1>Elm Street Community Garden</h1>
<p>Volunteers grow vegetables and herbs here every season.</p>
<div class="plot-map"></div>
<p>Plots are 3 by 4 metres.</p>
<h2 id="work-day">Next Work Day</h2>
<p class="event">
Saturday, November 28, from 9 a.m. to noon.
Bring <em>gloves</em>.
</p>
<h2 id="seed-swap">Spring Seed Swap</h2>
<p class="event family-friendly">
Sunday, March 21, from 2 p.m. to 4 p.m. Bring seeds to share.
</p>
<p>Questions? Email Rosa <[email protected]>.</p>
</main>
Next comes Exercise: Write the Work Day Notice, where you write Rosa a one-page notice for Saturday’s work day. You write and run your code in the browser, and automated tests tell you what passes and what to fix.