← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 881 · 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.🎯 Which element does the selector h2 style? (a) <div class="box"> (b) <li> (c) <h2 class="box"> (d) <span id="main">
  2. 2.🌈 In #002300 the green part is the hex number 23. What is it as a normal number?
  3. 3.Which of these is padding? (a) the line round the box (b) the gap round content (c) the text or picture (d) space outside the border
  4. 4.📱 max-width: 600px applies when the screen is ___. (a) turned off (b) exactly 1000px (c) 600px or wider (d) 600px or narrower
  5. 5.📦 In the box model, which part is space inside the border? (a) content (b) margin (c) padding (d) border
  6. 6.✍️ What value is given to font-size in this rule?
    body {
      color: red;
      font-size: 20px;
      border: 2px solid;
    }
    (a) 20px (b) center (c) font-size (d) yellow
  7. 7.✍️ What is the selector in this CSS rule?
    .box {
      font-size: 20px;
      color: red;
    }
    (a) font-size (b) .box (c) h2 (d) red
  8. 8.💪 Which flexbox property spaces boxes along a row? (a) gap (b) flex-direction (c) justify-content (d) display: flex
  9. 9.🌈 Which colour of light is strongest in rgb(36, 190, 114)? (a) green (b) red (c) blue
  10. 10.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 350px;
      justify-content: space-between;
    }
    Inside are 4 boxes, each 50px wide (no margins).
  11. 11.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 70px;
      padding: 15px;
      border: 3px solid black;
      margin: 15px;
    }
  12. 12.🖌️ Which CSS property makes the text bold? (a) font-family (b) font-weight (c) text-align (d) color
  13. 13.⚖️ What colour is the text of this element?
    <h1 class="note" id="top">Hi</h1>
    CSS:
    .note { color: red; }
    .note { color: white; }
    (a) purple (b) green (c) white (d) red
  14. 14.✍️ Which property is set to 300px in this rule?
    #top {
      font-style: italic;
      width: 300px;
    }
    (a) width (b) color (c) font-style (d) 300px
  15. 15.⚖️ What colour is the text of this element?
    <h1 class="big" id="top">Hi</h1>
    CSS:
    .big { color: green; }
    #top { color: red; }
    h1 { color: white; }
    (a) red (b) green (c) white (d) orange
  16. 16.✍️ What is the selector in this CSS rule?
    #top {
      width: 300px;
      font-size: 20px;
      padding: 8px;
      border: 2px solid;
    }
    (a) width (b) 20px (c) li (d) #top
  17. 17.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      width: 300px;
      margin: 10px;
    }
  18. 18.🧩 Which language gives the page structure? (a) CSS (b) HTML (c) JavaScript
  19. 19.📦 In the box model, which part is space outside the border? (a) padding (b) margin (c) content (d) border
  20. 20.What does justify-content: space-between 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
  21. 21.🎯 Which element does the selector p style? (a) <li id="intro"> (b) <p class="menu"> (c) <h2 class="menu"> (d) <h1>
  22. 22.💪 Which flexbox property turns on flexbox? (a) flex-direction (b) display: flex (c) align-items (d) justify-content
  23. 23.True or false: li is an element selector. (a) True (b) False
  24. 24.🌈 Which colour is #ffffff? (a) yellow (b) magenta (c) white (d) red
  25. 25.True or false: .star is an id selector. (a) True (b) False
  26. 26.🎯 Which CSS selector matches this element?
    <li class="note" id="end">Hello</li>
    (a) .end (b) #end (c) #hero (d) #note
  27. 27.🖌️ Where does the text sit on its line?
    h1 {
      font-size: 28px;
      text-align: center;
      color: green;
      background-color: blue;
    }
    (a) in the middle (b) on the left (c) on the right
  28. 28.🔍 Which is the odd one out? (a) shows a pop-up message (b) makes a form box (c) checks a quiz answer (d) reacts to a button click
  29. 29.🎯 Which element does the selector div style? (a) <p class="star"> (b) <span> (c) <h1 id="main"> (d) <div class="star">
  30. 30.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 8px;
      }
    }
  31. 31.🎯 Which CSS selector matches this element?
    <h1 class="menu" id="main">Hello</h1>
    (a) .main (b) #logo (c) h1 (d) .note
  32. 32.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      width: 300px;
      font-style: italic;
      margin: 10px;
      background-color: yellow;
    }
  33. 33.📱 What does a media query check? (a) the time of day (b) the page title (c) the battery level (d) the screen width
  34. 34.🎯 Which element does the selector #hero style? (a) <h1 id="hero"> (b) <h1 id="top"> (c) <h2 class="star"> (d) <h1 class="hero">
  35. 35.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 360px;
      justify-content: center;
    }
    Inside are 4 boxes, each 50px wide (no margins).
  36. 36.💪 Which justify-content value packs boxes at the end? (a) flex-start (b) flex-end (c) center (d) space-between
  37. 37.✍️ How many declarations (property: value pairs) are in this rule?
    .box {
      width: 300px;
      color: red;
      text-align: center;
      font-weight: bold;
    }
  38. 38.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 24px;
      }
    }
  39. 39.📱 The screen is 375px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 22px;
      }
    }
    (a) Yes (b) No
  40. 40.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 170px;
      justify-content: space-between;
    }
    Inside are 2 boxes, each 50px wide (no margins).

Answer key

  1. <h2 class="box">
  2. 35
  3. the gap round content
  4. 600px or narrower
  5. padding
  6. 20px
  7. .box
  8. justify-content
  9. green
  10. 50
  11. 136
  12. font-weight
  13. white
  14. width
  15. red
  16. #top
  17. 2
  18. HTML
  19. margin
  20. equal gaps, none at ends
  21. <p class="menu">
  22. display: flex
  23. True
  24. white
  25. False
  26. #end
  27. in the middle
  28. makes a form box
  29. <div class="star">
  30. 12
  31. h1
  32. 4
  33. the screen width
  34. <h1 id="hero">
  35. 80
  36. flex-end
  37. 4
  38. 24
  39. No
  40. 70

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