← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 350 · 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.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 160px;
      padding: 10px;
      border: 3px solid black;
      margin: 10px;
    }
  2. 2.🎯 Which CSS selector matches this element?
    <h2 class="menu" id="hero">Hello</h2>
    (a) #menu (b) .hero (c) h2 (d) .note
  3. 3.✍️ Which sign goes between a property and its value? (a) - (b) ; (c) = (d) :
  4. 4.📦 In the box model, which part is the gap to other boxes? (a) content (b) padding (c) border (d) margin
  5. 5.Which of these is margin? (a) a solid or dotted edge (b) space inside the border (c) the line round the box (d) space outside the border
  6. 6.True or false: padding is the gap round content. (a) True (b) False
  7. 7.✍️ How many declarations (property: value pairs) are in this rule?
    li {
      text-align: center;
      background-color: yellow;
      margin: 10px;
    }
  8. 8.🎯 Which element does the selector #logo style? (a) <h2 id="end"> (b) <li class="red"> (c) <h2 id="logo"> (d) <h2 class="logo">
  9. 9.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 260px;
      justify-content: flex-end;
    }
    Inside are 4 boxes, each 50px wide (no margins).
  10. 10.🧩 Which language checks a quiz answer? (a) CSS (b) JavaScript (c) HTML
  11. 11.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 22px;
      }
    }
    (a) No (b) Yes
  12. 12.✍️ What is the selector in this CSS rule?
    h2 {
      color: red;
      font-size: 20px;
      background-color: yellow;
      font-style: italic;
    }
    (a) color (b) h2 (c) h1 (d) 20px
  13. 13.💪 Which flexbox property turns on flexbox? (a) justify-content (b) align-items (c) display: flex (d) flex-direction
  14. 14.✍️ What is the selector in this CSS rule?
    .box {
      font-style: italic;
      border: 2px solid;
      font-size: 20px;
    }
    (a) 2px solid (b) font-style (c) h2 (d) .box
  15. 15.🖌️ Where does the text sit on its line?
    li {
      background-color: red;
      color: orange;
      font-size: 20px;
      text-align: right;
    }
    (a) on the right (b) in the middle (c) on the left
  16. 16.True or false: CSS puts a picture on a page. (a) False (b) True
  17. 17.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      text-align: center;
      color: red;
      margin: 10px;
      border: 2px solid;
    }
  18. 18.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 200px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 60px wide (no margins).
  19. 19.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 140px;
      padding: 15px;
      border: 3px solid black;
      margin: 0px;
    }
  20. 20.🎯 What kind of selector is .big? (a) a class selector (b) an id selector (c) an element selector
  21. 21.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 14px;
      }
    }
  22. 22.✍️ In color: blue; which part is the property? (a) blue (b) color (c) ; (d) :
  23. 23.🧩 Which language changes the page live? (a) CSS (b) JavaScript (c) HTML
  24. 24.⚖️ What colour is the text of this element?
    <h2 class="box" id="top">Hi</h2>
    CSS:
    .box { color: white; }
    .box { color: green; }
    (a) yellow (b) white (c) green (d) orange
  25. 25.🎯 Can many elements share the same class? (a) No (b) Yes
  26. 26.✍️ How many declarations (property: value pairs) are in this rule?
    li {
      width: 300px;
      background-color: yellow;
      font-weight: bold;
    }
  27. 27.🖌️ What colour is behind the letters?
    p {
      font-size: 40px;
      color: yellow;
      background-color: green;
      text-align: left;
    }
    (a) yellow (b) green (c) white
  28. 28.💪 Which justify-content value puts boxes in the middle? (a) flex-start (b) flex-end (c) center (d) space-between
  29. 29.✍️ How many declarations (property: value pairs) are in this rule?
    #top {
      padding: 8px;
    }
  30. 30.🎯 Which CSS selector matches this element?
    <span class="menu" id="intro">Hello</span>
    (a) .menu (b) .note (c) p (d) .intro
  31. 31.📱 The screen is 320px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 18px;
      }
    }
    (a) No (b) Yes
  32. 32.🌈 In #000300 the green part is the hex number 03. What is it as a normal number?
  33. 33.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 3 (b) 6 (c) 2 (d) 4
  34. 34.True or false: .star is an id selector. (a) True (b) False
  35. 35.What does justify-content: center do? (a) packs boxes at the start (b) puts boxes in the middle (c) equal gaps, none at ends (d) packs boxes at the end
  36. 36.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 280px;
      padding: 20px;
      border: 3px solid black;
      margin: 15px;
    }
  37. 37.🌈 Which colour is #ffffff? (a) blue (b) red (c) white (d) black
  38. 38.📱 The screen is 540px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 18px;
      }
    }
    (a) No (b) Yes
  39. 39.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 190px;
      justify-content: flex-end;
    }
    Inside are 4 boxes, each 40px wide (no margins).
  40. 40.⚖️ What colour is the text of this element?
    <p class="menu" id="logo">Hi</p>
    CSS:
    p { color: orange; }
    p { color: black; }
    (a) white (b) orange (c) black (d) blue

Answer key

  1. 206
  2. h2
  3. :
  4. margin
  5. space outside the border
  6. True
  7. 3
  8. <h2 id="logo">
  9. 60
  10. JavaScript
  11. No
  12. h2
  13. display: flex
  14. .box
  15. on the right
  16. False
  17. 4
  18. 80
  19. 176
  20. a class selector
  21. 20
  22. color
  23. JavaScript
  24. green
  25. Yes
  26. 3
  27. green
  28. center
  29. 1
  30. .menu
  31. Yes
  32. 3
  33. 3
  34. False
  35. puts boxes in the middle
  36. 356
  37. white
  38. Yes
  39. 30
  40. black

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