← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 442 · 40 questions
TalentJR

Code tip (Rule, then maths): Find the topic: syntax, selectors, properties, colours, box model, cascade, flexbox or media queries. Decide which rule or property applies to the element. For sizes, write the sum down: both sides for the box model, free space for flexbox.

NameDateTime takenScore ___ / 40
  1. 1.📦 In the box model, which part is space inside the border? (a) content (b) border (c) margin (d) padding
  2. 2.True or false: margin is space outside the border. (a) True (b) False
  3. 3.✍️ How many declarations (property: value pairs) are in this rule?
    #top {
      margin: 10px;
    }
  4. 4.📱 The screen is 820px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 22px;
      }
    }
    (a) Yes (b) No
  5. 5.📱 What does a media query check? (a) the time of day (b) the screen width (c) the battery level (d) the page title
  6. 6.🖌️ Where does the text sit on its line?
    h1 {
      background-color: blue;
      color: white;
      font-size: 24px;
      text-align: right;
    }
    (a) on the left (b) on the right (c) in the middle
  7. 7.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      font-style: italic;
      font-weight: bold;
      text-align: center;
      margin: 10px;
    }
  8. 8.What does background-color do? (a) centres a heading (b) colours behind the text (c) makes the text bold (d) sets the letter colour
  9. 9.True or false: .card is a class selector. (a) True (b) False
  10. 10.✍️ In color: blue; which part is the value? (a) color (b) blue (c) : (d) ;
  11. 11.🌈 Which colour is #00ffff? (a) white (b) cyan (c) magenta (d) yellow
  12. 12.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 70px;
      padding: 5px;
      border: 2px solid black;
      margin: 0px;
    }
  13. 13.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the later one (b) the shorter one (c) the first one (d) neither
  14. 14.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 130px;
      padding: 30px;
      border: 4px solid black;
      margin: 10px;
    }
  15. 15.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 22px;
      }
    }
  16. 16.🎯 Which CSS selector matches this element?
    <span class="red" id="main">Hello</span>
    (a) #logo (b) .main (c) p (d) span
  17. 17.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 190px;
      padding: 5px;
      border: 1px solid black;
      margin: 0px;
    }
  18. 18.🎯 Which sign starts a class selector? (a) & (b) . (c) # (d) @
  19. 19.🌈 Which colour is rgb(255, 0, 0)? (a) cyan (b) red (c) white (d) magenta
  20. 20.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 16px;
      }
    }
  21. 21.True or false: .menu is an id selector. (a) False (b) True
  22. 22.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 280px;
      justify-content: center;
    }
    Inside are 4 boxes, each 50px wide (no margins).
  23. 23.True or false: CSS adds space around boxes. (a) True (b) False
  24. 24.🎯 Which element does the selector p style? (a) <h2 class="note"> (b) <h1> (c) <li id="intro"> (d) <p class="note">
  25. 25.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      font-weight: bold;
      font-size: 20px;
      margin: 10px;
      padding: 8px;
    }
  26. 26.✍️ Which property is set to bold in this rule?
    body {
      color: red;
      border: 2px solid;
      padding: 8px;
      font-weight: bold;
    }
    (a) width (b) bold (c) font-weight (d) border
  27. 27.What does color do? (a) colours behind the text (b) centres a heading (c) makes letters bigger (d) sets the letter colour
  28. 28.✍️ How does a CSS comment start? (a) /* (b) # (c) // (d) <!--
  29. 29.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 340px;
      justify-content: flex-end;
    }
    Inside are 4 boxes, each 80px wide (no margins).
  30. 30.🎯 Which element does the selector .big style? (a) <span class="box"> (b) <div class="big"> (c) <div class="red"> (d) <div id="big">
  31. 31.🖌️ What colour are the letters?
    h1 {
      text-align: right;
      background-color: black;
      font-size: 40px;
      color: blue;
    }
    (a) yellow (b) blue (c) black
  32. 32.🌈 Which hex code is red? (a) #00ffff (b) #ffff00 (c) #ffffff (d) #ff0000
  33. 33.🌈 Which colour is #000000? (a) white (b) yellow (c) blue (d) black
  34. 34.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      padding: 8px;
    }
  35. 35.🎯 Which CSS selector matches this element?
    <li class="star" id="logo">Hello</li>
    (a) div (b) #star (c) li (d) #end
  36. 36.True or false: #hero is a class selector. (a) False (b) True
  37. 37.True or false: CSS rounds box corners. (a) False (b) True
  38. 38.🎯 Which CSS selector matches this element?
    <p class="note" id="top">Hello</p>
    (a) .big (b) #note (c) .note (d) #intro
  39. 39.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
  40. 40.🖌️ Which CSS property colours behind the text? (a) font-size (b) font-family (c) background-color (d) color

Answer key

  1. padding
  2. True
  3. 1
  4. Yes
  5. the screen width
  6. on the right
  7. 4
  8. colours behind the text
  9. True
  10. blue
  11. cyan
  12. 84
  13. the later one
  14. 218
  15. 22
  16. span
  17. 202
  18. .
  19. red
  20. 16
  21. False
  22. 40
  23. True
  24. <p class="note">
  25. 4
  26. font-weight
  27. sets the letter colour
  28. /*
  29. 20
  30. <div class="big">
  31. blue
  32. #ff0000
  33. black
  34. 1
  35. li
  36. False
  37. True
  38. .note
  39. an element selector
  40. background-color

Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids