Div: the block container, online

Six activities your students do on their own devices. See who's finished, and their scores.

Div: the block container in one minute

What students need to know

The <div> wraps the heading and paragraph into one group. CSS targeting .hero applies styling to the whole block. id="sidebar" uniquely identifies this div. CSS can use #sidebar { } to position and style this block.

<div> has no built-in visual styling. It is a neutral container - all styling must be added with CSS. <div> is block-level - it starts on a new line and expands to fill its parent's full width. Use <span> for inline grouping.

Mistakes students make

  • HTML tag names must be lowercase. <DIV> should be written as <div>.
  • The h1 closing tag is missing its forward slash. It should be </h1> not <h1>.
  • There must be no space between = and the opening quote. The correct form is class="box".
  • The last inner div is missing its closing forward slash. It should be </div> not <div> at the end.

Discover other journeys with this module

What students will learn in this module

Every question in Module 20

Quick questions

  1. True or false: <div> adds visible styling like a border or background by default.AFalseBTrue
  2. Is <div> a block-level or inline element?ABlock-levelBInline
  3. What attribute is commonly used on <div> to give CSS a styling target?AstyleBclass
  4. True or false: divs can be nested inside other divs.AFalseBTrue
  5. True or false: <DIV> with capital letters is valid HTML.AFalseBTrue

Key terms

Students type the meaning of:

  • <div>

Match the pairs

<div class="card">
  <p>Card content.</p>
</div>
Match it to what it does
<div class="grid">
  <div class="cell">A</div>
  <div class="cell">B</div>
</div>
Match it to what it does
<div> is a block-level container with no built-in styling - all appearance comes from CSSMatch it to what it does
class and id on <div> give CSS a target to apply styles to that blockMatch it to what it does
<DIV class="card">
  <p>Text.</p>
</DIV>
Match it to what it does
<div class="row">
  </div class="row">
Match it to what it does

Fill in the blanks

  1. <___ class="card">
      <p>Content.</p>
    </div>

    Hint: Type the block container element name used to group content

  2. <div ___="hero">
      <h1>Welcome</h1>
    </div>

    Hint: Type the attribute name used to assign a CSS class to this div

  3. <div class="box">
      <p>Text here.</p>
    </___>

    Hint: Type the element name for the closing tag that ends this block container

  4. <div class="outer">
      <___ class="inner">
      </div>
    </div>

    Hint: Type the element name for the nested block container inside the outer div

  5. <div ___="main-content">
      <p>Main area.</p>
    </div>

    Hint: Type the attribute name used to give this div a unique identifier

Spot the error

Question 1

A<DIV class="card">B  <p>Hello world.</p>C</div>

Question 2

A<div class="hero">B  <h1>Welcome<h1>C  <p>Intro text.</p>D</div>

Question 3

A<div class="sidebar">B  <p>Side content.</p>C  <div class= "box">D  </div>E</div>

Question 4

A<div class="grid">B  <div class="cell">A</div>C  <div class="cell">B</div>D  <div class="cell">C<div>E</div>

Question 5

A<main>B  <div class="wrapper">C    <p>Main content.</p>D  </div>E  <div>Extra.</divF</main>