← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 930 · 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.🖌️ What colour is behind the letters?
    h1 {
      font-size: 36px;
      text-align: left;
      color: black;
      background-color: blue;
    }
    (a) blue (b) purple (c) black
  2. 2.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 320px;
      justify-content: center;
    }
    Inside are 2 boxes, each 100px wide (no margins).
  3. 3.True or false: .menu is a class selector. (a) False (b) True
  4. 4.⚖️ What colour is the text of this element?
    <p class="red" id="logo">Hi</p>
    CSS:
    .red { color: yellow; }
    .red { color: green; }
    (a) yellow (b) black (c) green (d) orange
  5. 5.🎯 Which CSS selector matches this element?
    <h2 class="note" id="intro">Hello</h2>
    (a) .big (b) .intro (c) #main (d) .note
  6. 6.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 140px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 60px wide (no margins).
  7. 7.🎯 Which sign starts an id selector? (a) . (b) & (c) # (d) @
  8. 8.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 120px;
      justify-content: center;
    }
    Inside are 2 boxes, each 50px wide (no margins).
  9. 9.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) neither (c) the shorter one (d) the later one
  10. 10.What does justify-content: center do? (a) puts boxes in the middle (b) equal gaps, none at ends (c) packs boxes at the end (d) packs boxes at the start
  11. 11.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
  12. 12.✍️ How many declarations (property: value pairs) are in this rule?
    li {
      margin: 10px;
      font-size: 20px;
      background-color: yellow;
    }
  13. 13.True or false: margin is the gap round content. (a) False (b) True
  14. 14.True or false: padding is the gap round content. (a) False (b) True
  15. 15.🖌️ What colour are the letters?
    p {
      background-color: white;
      font-size: 28px;
      text-align: center;
      color: purple;
    }
    (a) white (b) red (c) purple
  16. 16.True or false: .menu is an element selector. (a) False (b) True
  17. 17.🧩 Which language makes headings and lists? (a) CSS (b) JavaScript (c) HTML
  18. 18.✍️ Which sign goes between a property and its value? (a) ; (b) = (c) : (d) -
  19. 19.What does justify-content: space-between do? (a) equal gaps, none at ends (b) puts boxes in the middle (c) packs boxes at the end (d) packs boxes at the start
  20. 20.🖌️ Where does the text sit on its line?
    h2 {
      color: black;
      background-color: red;
      text-align: center;
      font-size: 12px;
    }
    (a) on the left (b) in the middle (c) on the right
  21. 21.✍️ How many declarations (property: value pairs) are in this rule?
    #top {
      font-weight: bold;
    }
  22. 22.⚖️ What colour is the text of this element?
    <h2 class="menu" id="logo">Hi</h2>
    CSS:
    .menu { color: green; }
    .menu { color: blue; }
    (a) yellow (b) blue (c) red (d) green
  23. 23.✍️ What value is given to background-color in this rule?
    h2 {
      margin: 10px;
      font-weight: bold;
      background-color: yellow;
    }
    (a) 10px (b) 8px (c) background-color (d) yellow
  24. 24.📱 The screen is 700px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 22px;
      }
    }
    (a) No (b) Yes
  25. 25.🖌️ Which CSS property sets the letter colour? (a) font-weight (b) color (c) background-color (d) font-family
  26. 26.🎯 Which element does the selector h2 style? (a) <div class="big"> (b) <h2 class="big"> (c) <span id="intro"> (d) <li>
  27. 27.🌈 Which colour is #ffffff? (a) blue (b) cyan (c) red (d) white
  28. 28.🖌️ What colour are the letters?
    li {
      background-color: black;
      font-size: 40px;
      color: orange;
      text-align: left;
    }
    (a) black (b) yellow (c) orange
  29. 29.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 220px;
      justify-content: flex-end;
    }
    Inside are 2 boxes, each 100px wide (no margins).
  30. 30.🌈 In #4c0000 the red part is the hex number 4c. What is it as a normal number?
  31. 31.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) red (c) black (d) blue
  32. 32.📱 The screen is 320px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 10px;
      }
    }
    (a) No (b) Yes
  33. 33.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 320px;
      justify-content: center;
    }
    Inside are 4 boxes, each 50px wide (no margins).
  34. 34.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 28px;
      }
    }
  35. 35.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 220px;
      padding: 20px;
      border: 4px solid black;
      margin: 15px;
    }
  36. 36.🖌️ How big is the text, in px?
    h1 {
      color: orange;
      background-color: green;
      font-size: 32px;
      text-align: left;
    }
  37. 37.💪 Which flexbox property lines boxes up across? (a) justify-content (b) align-items (c) flex-direction (d) gap
  38. 38.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 170px;
      justify-content: flex-end;
    }
    Inside are 3 boxes, each 40px wide (no margins).
  39. 39.🖌️ Which CSS property picks the font style? (a) font-family (b) font-weight (c) background-color (d) font-size
  40. 40.🌈 Which hex code is blue? (a) #0000ff (b) #ffff00 (c) #00ff00 (d) #ff00ff

Answer key

  1. blue
  2. 60
  3. True
  4. green
  5. .note
  6. 20
  7. #
  8. 10
  9. the later one
  10. puts boxes in the middle
  11. an element selector
  12. 3
  13. False
  14. True
  15. purple
  16. False
  17. HTML
  18. :
  19. equal gaps, none at ends
  20. in the middle
  21. 1
  22. blue
  23. yellow
  24. No
  25. color
  26. <h2 class="big">
  27. white
  28. orange
  29. 20
  30. 76
  31. red
  32. Yes
  33. 60
  34. 20
  35. 268
  36. 32
  37. align-items
  38. 50
  39. font-family
  40. #0000ff

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