← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 720 · 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 does justify-content: flex-start do? (a) equal gaps, none at ends (b) packs boxes at the start (c) packs boxes at the end (d) puts boxes in the middle
  2. 2.🎯 Which element does the selector #end style? (a) <div class="end"> (b) <div id="end"> (c) <div id="hero"> (d) <span class="box">
  3. 3.💪 Which justify-content value puts boxes in the middle? (a) flex-start (b) center (c) space-between (d) flex-end
  4. 4.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 150px;
      justify-content: flex-end;
    }
    Inside are 3 boxes, each 40px wide (no margins).
  5. 5.✍️ How many declarations (property: value pairs) are in this rule?
    li {
      padding: 8px;
    }
  6. 6.🎯 Which element does the selector div style? (a) <h1 id="intro"> (b) <span> (c) <p class="big"> (d) <div class="big">
  7. 7.🌈 Which colour is #ffff00? (a) red (b) magenta (c) yellow (d) blue
  8. 8.✍️ Which sign goes between a property and its value? (a) = (b) : (c) - (d) ;
  9. 9.🖌️ What colour is behind the letters?
    li {
      background-color: green;
      text-align: center;
      color: red;
      font-size: 28px;
    }
    (a) green (b) red (c) yellow
  10. 10.🎯 What kind of selector is .big? (a) a class selector (b) an id selector (c) an element selector
  11. 11.📱 The screen is 1100px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 14px;
      }
    }
    (a) Yes (b) No
  12. 12.💪 Which flexbox property spaces boxes along a row? (a) display: flex (b) gap (c) flex-direction (d) justify-content
  13. 13.✍️ What value is given to width in this rule?
    body {
      width: 300px;
      border: 2px solid;
      font-weight: bold;
    }
    (a) red (b) 300px (c) italic (d) width
  14. 14.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) neither (c) the first one (d) the later one
  15. 15.🌈 In #rrggbb, which colour do the last two digits give? (a) red (b) white (c) blue (d) green
  16. 16.🖌️ Where does the text sit on its line?
    h2 {
      background-color: purple;
      text-align: left;
      font-size: 32px;
      color: red;
    }
    (a) in the middle (b) on the right (c) on the left
  17. 17.🌈 In #rrggbb, which colour do the first two digits give? (a) red (b) blue (c) green (d) black
  18. 18.🎯 What kind of selector is body? (a) a class selector (b) an id selector (c) an element selector
  19. 19.💪 Which flexbox property sets space between boxes? (a) display: flex (b) justify-content (c) flex-direction (d) gap
  20. 20.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 450px;
      justify-content: space-between;
    }
    Inside are 4 boxes, each 60px wide (no margins).
  21. 21.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
  22. 22.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) 800px or narrower (c) 800px or wider (d) exactly 100px
  23. 23.📱 The screen is 700px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 18px;
      }
    }
    (a) Yes (b) No
  24. 24.🎨 Which tag connects an outside CSS file? (a) <a> (b) <css> (c) <link> (d) <img>
  25. 25.True or false: HTML makes headings and lists. (a) True (b) False
  26. 26.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 160px;
      justify-content: center;
    }
    Inside are 2 boxes, each 50px wide (no margins).
  27. 27.🧩 Which language puts a picture on a page? (a) CSS (b) HTML (c) JavaScript
  28. 28.⚖️ What colour is the text of this element?
    <h2 class="big" id="top">Hi</h2>
    CSS:
    h2 { color: orange; }
    .big { color: red; }
    #top { color: black; }
    (a) red (b) orange (c) green (d) black
  29. 29.🧩 Which language makes a form box? (a) HTML (b) JavaScript (c) CSS
  30. 30.📱 What does a media query check? (a) the time of day (b) the screen width (c) the battery level (d) the page title
  31. 31.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 150px;
      padding: 15px;
      border: 5px solid black;
      margin: 0px;
    }
  32. 32.🖌️ Where does the text sit on its line?
    p {
      text-align: left;
      background-color: black;
      font-size: 20px;
      color: white;
    }
    (a) in the middle (b) on the left (c) on the right
  33. 33.✍️ How many declarations (property: value pairs) are in this rule?
    .box {
      font-style: italic;
      color: red;
    }
  34. 34.🖌️ What colour is behind the letters?
    p {
      font-size: 12px;
      text-align: right;
      background-color: red;
      color: black;
    }
    (a) red (b) orange (c) black
  35. 35.🌈 Which hex code is yellow? (a) #ff00ff (b) #ffff00 (c) #ffffff (d) #000000
  36. 36.✍️ What is the selector in this CSS rule?
    li {
      font-size: 20px;
      text-align: center;
      padding: 8px;
    }
    (a) li (b) font-size (c) center (d) body
  37. 37.🌈 Which colour is rgb(0, 0, 255)? (a) red (b) bright green (c) blue (d) cyan
  38. 38.⚖️ Which selector is the weakest? (a) an element selector (b) a class selector (c) an id selector
  39. 39.🎯 Which CSS selector matches this element?
    <li class="star" id="main">Hello</li>
    (a) .menu (b) #star (c) div (d) li
  40. 40.📦 In the box model, which part is the text or picture? (a) content (b) border (c) margin (d) padding

Answer key

  1. packs boxes at the start
  2. <div id="end">
  3. center
  4. 30
  5. 1
  6. <div class="big">
  7. yellow
  8. :
  9. green
  10. a class selector
  11. No
  12. justify-content
  13. 300px
  14. the later one
  15. blue
  16. on the left
  17. red
  18. an element selector
  19. gap
  20. 70
  21. an id selector
  22. 800px or wider
  23. Yes
  24. <link>
  25. True
  26. 30
  27. HTML
  28. black
  29. HTML
  30. the screen width
  31. 190
  32. on the left
  33. 2
  34. red
  35. #ffff00
  36. li
  37. blue
  38. an element selector
  39. li
  40. content

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