Border, online

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

Border in one minute

What students need to know

border-style controls the visual pattern of the border line and accepts values such as solid, dashed, dotted, and none. border-width is the individual property for setting border thickness, separate from style and color.

CSS has four directional border properties: border-top, border-right, border-bottom, and border-left. border-edge-top does not exist. thick is a keyword value for border-width. Its exact pixel size depends on the browser, but is typically around 5px — it does not mean 100px.

Mistakes students make

  • The shorthand order is wrong. CSS border shorthand requires width first, then style, then color: border: 2px solid red; not solid 2px red.
  • The property name is misspelled. border-styl is missing the letter e at the end — it should be border-style: dashed;.
  • The h2 selector is fine, but the border shorthand on line 2 is incomplete. A border value without a color is technically valid but relies on currentColor — however a missing style value would make the border invisible. Here the color is omitted; add a color: border: 3px dotted black;.
  • colour is not valid CSS — CSS uses American English. The correct property is border-color: navy;.
PREVIOUS · MODULE 46Padding
YOU ARE HERE · MODULE 47Border
NEXT · MODULE 48Margin

Discover other journeys with this module

What students will learn in this module

Every question in Module 47

Quick questions

  1. What is the correct order for the border shorthand?Astyle width colorBwidth style color
  2. Which border-style value creates a continuous unbroken line?AsolidBdashed
  3. Does border: none remove a border completely?AYesBNo — it sets the color to none
  4. Which property applies a border only to the top edge?Aborder-topBborder-edge-top
  5. Is border: 1px black valid CSS?AYes — style defaults to solidBNo — the style value is missing

Key terms

Students type the meaning of:

  • border

Match the pairs

border: 2px solid blackMatch it to what it does
border-top: 1px dashed redMatch it to what it does
Sets the line style of all four borders at onceMatch it to what it does
Controls only the thickness of a borderMatch it to what it does
border: solid 2px blueMatch it to what it does
border-colour: redMatch it to what it does

Fill in the blanks

  1. p {
      border: 2px _____ red;
    }

    Hint: Type the border-style value that produces a continuous unbroken line

  2. div {
      ____________: blue;
    }

    Hint: Type the individual CSS property that sets only the colour of a border

  3. .box {
      ____________: 3px;
    }

    Hint: Type the individual CSS property that sets only the thickness of a border

  4. p {
      border: 1px ______ black;
    }

    Hint: Type the border-style value that produces a series of short dashes

  5. h2 {
      ____________: dotted;
    }

    Hint: Type the individual CSS property that sets only the line style of a border

Spot the error

Question 1

Ap {B  border: solid 2px red;C}

Question 2

A.card {B  border-width: 1px;C  border-styl: dashed;D  border-color: gray;E}

Question 3

Ah2 {B  border: 3px dotted;C}

Question 4

Adiv {B  border-top: 2px solid navy;C  border-bottom: 2px solid navy;D  border-colour: navy;E}

Question 5

Ap {B  border: 0px solid black;C}