← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 165 · 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 value is given to padding in this rule?
    .box {
      text-align: center;
      width: 300px;
      padding: 8px;
    }
    (a) bold (b) 8px (c) 2px solid (d) padding
  2. 2.⚖️ What colour is the text of this element?
    <h2 class="note" id="main">Hi</h2>
    CSS:
    h2 { color: white; }
    #main { color: green; }
    (a) red (b) green (c) white (d) yellow
  3. 3.⚖️ What colour is the text of this element?
    <p class="menu" id="main">Hi</p>
    CSS:
    p { color: white; }
    .menu { color: black; }
    (a) red (b) black (c) white (d) purple
  4. 4.🌈 Which hex code is red? (a) #00ff00 (b) #000000 (c) #ff0000 (d) #ffffff
  5. 5.🧩 Which language puts a picture on a page? (a) HTML (b) JavaScript (c) CSS
  6. 6.⚖️ What colour is the text of this element?
    <p class="note" id="logo">Hi</p>
    CSS:
    p { color: yellow; }
    p { color: black; }
    (a) black (b) purple (c) red (d) yellow
  7. 7.What does justify-content: space-between do? (a) packs boxes at the end (b) packs boxes at the start (c) equal gaps, none at ends (d) puts boxes in the middle
  8. 8.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 100px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 40px wide (no margins).
  9. 9.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 520px;
      justify-content: space-between;
    }
    Inside are 4 boxes, each 100px wide (no margins).
  10. 10.🎯 Which sign starts a class selector? (a) . (b) @ (c) # (d) &
  11. 11.✍️ Which sign goes between a property and its value? (a) ; (b) = (c) - (d) :
  12. 12.✍️ How many declarations (property: value pairs) are in this rule?
    li {
      width: 300px;
      font-style: italic;
      font-size: 20px;
    }
  13. 13.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 190px;
      justify-content: space-between;
    }
    Inside are 2 boxes, each 80px wide (no margins).
  14. 14.🖌️ Where does the text sit on its line?
    p {
      font-size: 16px;
      background-color: black;
      color: white;
      text-align: center;
    }
    (a) on the right (b) in the middle (c) on the left
  15. 15.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 16px;
      }
    }
  16. 16.What does justify-content: center do? (a) puts boxes in the middle (b) packs boxes at the end (c) packs boxes at the start (d) equal gaps, none at ends
  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: 120px;
      padding: 5px;
      border: 4px solid black;
      margin: 15px;
    }
  18. 18.⚖️ What colour is the text of this element?
    <h2 class="red" id="main">Hi</h2>
    CSS:
    #main { color: white; }
    #main { color: blue; }
    (a) purple (b) red (c) white (d) blue
  19. 19.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 30px;
      }
    }
  20. 20.✍️ Which property is set to yellow in this rule?
    h1 {
      margin: 10px;
      background-color: yellow;
      font-style: italic;
    }
    (a) padding (b) background-color (c) margin (d) yellow
  21. 21.What does background-color do? (a) makes letters bigger (b) centres a heading (c) sets the letter colour (d) colours behind the text
  22. 22.⚖️ Which selector is the weakest? (a) an id selector (b) an element selector (c) a class selector
  23. 23.🖌️ What colour are the letters?
    p {
      background-color: black;
      font-size: 12px;
      text-align: left;
      color: yellow;
    }
    (a) yellow (b) black (c) purple
  24. 24.✍️ What is the selector in this CSS rule?
    li {
      font-style: italic;
      font-weight: bold;
      text-align: center;
      font-size: 20px;
    }
    (a) bold (b) body (c) font-style (d) li
  25. 25.📱 The screen is 320px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 18px;
      }
    }
    (a) No (b) Yes
  26. 26.🖌️ What colour are the letters?
    h2 {
      font-size: 16px;
      background-color: green;
      text-align: right;
      color: red;
    }
    (a) purple (b) green (c) red
  27. 27.💪 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 50px wide (no margins).
  28. 28.🌈 Which colour is #00ff00? (a) black (b) yellow (c) bright green (d) cyan
  29. 29.🖌️ Where does the text sit on its line?
    h2 {
      background-color: yellow;
      text-align: right;
      font-size: 24px;
      color: green;
    }
    (a) on the left (b) on the right (c) in the middle
  30. 30.Which of these is margin? (a) a solid or dotted edge (b) space outside the border (c) the gap round content (d) space inside the border
  31. 31.Which of these does JavaScript do? (a) checks a quiz answer (b) lays out the page (c) gives the page structure (d) changes the text size
  32. 32.✍️ Which property is set to red in this rule?
    .box {
      text-align: center;
      color: red;
    }
    (a) color (b) font-size (c) red (d) text-align
  33. 33.🌈 Which hex code is yellow? (a) #000000 (b) #ffffff (c) #00ffff (d) #ffff00
  34. 34.✍️ In color: blue; which part is the property? (a) : (b) blue (c) color (d) ;
  35. 35.💪 Which flexbox property lines boxes up across? (a) flex-direction (b) justify-content (c) gap (d) align-items
  36. 36.⚖️ What colour is the text of this element?
    <h2 class="box" id="top">Hi</h2>
    CSS:
    .box { color: purple; }
    h2 { color: white; }
    (a) white (b) purple (c) yellow (d) blue
  37. 37.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      font-weight: bold;
      font-size: 20px;
      color: red;
    }
  38. 38.What does font-weight do? (a) makes the text bold (b) centres a heading (c) sets the letter colour (d) picks the font style
  39. 39.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 18px;
      }
    }
  40. 40.💪 Which flexbox property sets space between boxes? (a) justify-content (b) align-items (c) display: flex (d) gap

Answer key

  1. 8px
  2. green
  3. black
  4. #ff0000
  5. HTML
  6. black
  7. equal gaps, none at ends
  8. 20
  9. 40
  10. .
  11. :
  12. 3
  13. 30
  14. in the middle
  15. 20
  16. puts boxes in the middle
  17. 138
  18. blue
  19. 30
  20. background-color
  21. colours behind the text
  22. an element selector
  23. yellow
  24. li
  25. No
  26. red
  27. 40
  28. bright green
  29. on the right
  30. space outside the border
  31. checks a quiz answer
  32. color
  33. #ffff00
  34. color
  35. align-items
  36. purple
  37. 3
  38. makes the text bold
  39. 18
  40. gap

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