×

css · level 1 · unit 6 · lesson 4

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

boxes stack up; boxes sit in a line.

says how a box takes up space. A block box, like <p>, <h1> or <div>, starts on a new line and stretches across the whole width.

An inline box sits inside a line of text, only as wide as its words. <span> marks a few words to style. <a> is a link, and its href says where it goes. Both are inline.

You can switch: display: block puts a link on its own line, and display: inline lines block boxes up like words. Inline boxes ignore width and height.

<p>I love <span class="hi">pancakes</span> with jam.</p>
<a href="https://example.com/recipes">Recipes</a>
<a href="https://example.com/shop">Shop</a>
.hi {
  background-color: yellow;
}
a {
  display: block;
}

Press show my page to see it here.

Delete the a rule and the two links sit side by side again.