← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 742 · 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.📦 In the box model, which part is the line round the box? (a) margin (b) content (c) border (d) padding
  2. 2.✍️ Which property is set to center in this rule?
    h2 {
      font-size: 20px;
      text-align: center;
    }
    (a) center (b) background-color (c) margin (d) text-align
  3. 3.🖌️ Where does the text sit on its line?
    p {
      color: purple;
      text-align: right;
      font-size: 20px;
      background-color: black;
    }
    (a) on the right (b) on the left (c) in the middle
  4. 4.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the first one (c) neither (d) the later one
  5. 5.⚖️ Which selector is the weakest? (a) an element selector (b) a class selector (c) an id selector
  6. 6.🌈 Which colour is rgb(255, 255, 0)? (a) white (b) yellow (c) cyan (d) magenta
  7. 7.🎯 Which element does the selector h1 style? (a) <h2> (b) <h1 class="menu"> (c) <li class="menu"> (d) <div id="intro">
  8. 8.✍️ What is the selector in this CSS rule?
    li {
      margin: 10px;
      border: 2px solid;
    }
    (a) margin (b) li (c) 2px solid (d) body
  9. 9.🎨 Which tag holds CSS inside the head? (a) <style> (b) <body> (c) <css> (d) <script>
  10. 10.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 280px;
      justify-content: space-between;
    }
    Inside are 4 boxes, each 40px wide (no margins).
  11. 11.✍️ Which sign ends each CSS declaration? (a) . (b) : (c) , (d) ;
  12. 12.✍️ In color: blue; which part is the value? (a) blue (b) color (c) ; (d) :
  13. 13.💪 Which flexbox property picks row or column? (a) display: flex (b) gap (c) justify-content (d) flex-direction
  14. 14.💪 Which justify-content value equal gaps, none at ends? (a) flex-start (b) center (c) flex-end (d) space-between
  15. 15.🖌️ Where does the text sit on its line?
    h1 {
      font-size: 20px;
      background-color: white;
      text-align: right;
      color: red;
    }
    (a) in the middle (b) on the left (c) on the right
  16. 16.⚖️ What colour is the text of this element?
    <h1 class="menu" id="logo">Hi</h1>
    CSS:
    h1 { color: yellow; }
    h1 { color: black; }
    (a) yellow (b) white (c) red (d) black
  17. 17.True or false: padding is space outside the border. (a) False (b) True
  18. 18.🌈 What is the biggest number one colour can have in rgb()? (a) 255 (b) 1000 (c) 100 (d) 99
  19. 19.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 90px;
      padding: 25px;
      border: 5px solid black;
      margin: 0px;
    }
  20. 20.✍️ How does a CSS comment start? (a) /* (b) <!-- (c) # (d) //
  21. 21.What does justify-content: center do? (a) puts boxes in the middle (b) equal gaps, none at ends (c) packs boxes at the start (d) packs boxes at the end
  22. 22.🧩 Which language reacts to a button click? (a) HTML (b) CSS (c) JavaScript
  23. 23.🎯 Which CSS selector matches this element?
    <h1 class="note" id="intro">Hello</h1>
    (a) h1 (b) #main (c) .intro (d) #note
  24. 24.✍️ Which property is set to 10px in this rule?
    p {
      font-weight: bold;
      font-size: 20px;
      color: red;
      margin: 10px;
    }
    (a) padding (b) font-weight (c) 10px (d) margin
  25. 25.🔍 Which is the odd one out? (a) counts down a timer (b) reacts to a button click (c) changes the page live (d) makes a link
  26. 26.Which of these is margin? (a) space inside the border (b) space outside the border (c) the gap round content (d) the text or picture
  27. 27.🧩 Which language shows a pop-up message? (a) JavaScript (b) HTML (c) CSS
  28. 28.🧩 Which language checks a quiz answer? (a) JavaScript (b) CSS (c) HTML
  29. 29.🖌️ How big is the text, in px?
    h2 {
      color: black;
      background-color: purple;
      font-size: 32px;
      text-align: right;
    }
  30. 30.🎯 Can many elements share the same class? (a) Yes (b) No
  31. 31.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
  32. 32.🎯 Which element does the selector .star style? (a) <h1 class="star"> (b) <h2 class="note"> (c) <h1 id="star"> (d) <h1 class="menu">
  33. 33.📦 In the box model, which part is space outside the border? (a) margin (b) padding (c) content (d) border
  34. 34.📱 Which tag helps phones show a page at the right size? (a) the hr tag (b) the br tag (c) the title tag (d) the viewport meta tag
  35. 35.✍️ In color: blue; which part is the property? (a) blue (b) ; (c) : (d) color
  36. 36.🎯 Which element does the selector #end style? (a) <p class="end"> (b) <p id="hero"> (c) <h1 class="box"> (d) <p id="end">
  37. 37.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 190px;
      padding: 30px;
      border: 1px solid black;
      margin: 0px;
    }
  38. 38.🎯 Which sign starts a class selector? (a) . (b) @ (c) & (d) #
  39. 39.📱 The screen is 540px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 18px;
      }
    }
    (a) Yes (b) No
  40. 40.True or false: padding is the text or picture. (a) True (b) False

Answer key

  1. border
  2. text-align
  3. on the right
  4. the later one
  5. an element selector
  6. yellow
  7. <h1 class="menu">
  8. li
  9. <style>
  10. 40
  11. ;
  12. blue
  13. flex-direction
  14. space-between
  15. on the right
  16. black
  17. False
  18. 255
  19. 150
  20. /*
  21. puts boxes in the middle
  22. JavaScript
  23. h1
  24. margin
  25. makes a link
  26. space outside the border
  27. JavaScript
  28. JavaScript
  29. 32
  30. Yes
  31. an id selector
  32. <h1 class="star">
  33. margin
  34. the viewport meta tag
  35. color
  36. <p id="end">
  37. 252
  38. .
  39. Yes
  40. False

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