← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 226 · 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 is the selector in this CSS rule?
    h1 {
      font-weight: bold;
      border: 2px solid;
      text-align: center;
      width: 300px;
    }
    (a) font-weight (b) 2px solid (c) h1 (d) p
  2. 2.True or false: #logo is an element selector. (a) True (b) False
  3. 3.🧩 Which language checks a quiz answer? (a) HTML (b) JavaScript (c) CSS
  4. 4.⚖️ What colour is the text of this element?
    <h2 class="menu" id="logo">Hi</h2>
    CSS:
    h2 { color: yellow; }
    h2 { color: blue; }
    (a) yellow (b) orange (c) blue (d) purple
  5. 5.Which of these is the content? (a) space outside the border (b) the gap to other boxes (c) a solid or dotted edge (d) the text or picture
  6. 6.🌈 Which colour is rgb(255, 255, 255)? (a) white (b) black (c) magenta (d) red
  7. 7.🎯 Which element does the selector .menu style? (a) <div class="menu"> (b) <div id="menu"> (c) <span class="big"> (d) <div class="note">
  8. 8.🖌️ What colour is behind the letters?
    h2 {
      text-align: right;
      color: orange;
      font-size: 36px;
      background-color: black;
    }
    (a) orange (b) green (c) black
  9. 9.📦 In the box model, which part is the line round the box? (a) padding (b) content (c) margin (d) border
  10. 10.🎯 What kind of selector is .note? (a) a class selector (b) an element selector (c) an id selector
  11. 11.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      width: 300px;
    }
  12. 12.True or false: HTML reacts to a button click. (a) False (b) True
  13. 13.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
  14. 14.🎨 Which attribute adds CSS inside one tag? (a) alt (b) src (c) style (d) href
  15. 15.⚖️ What colour is the text of this element?
    <p class="box" id="hero">Hi</p>
    CSS:
    #hero { color: purple; }
    #hero { color: blue; }
    (a) purple (b) yellow (c) white (d) blue
  16. 16.🎯 Which CSS selector matches this element?
    <h1 class="box" id="logo">Hello</h1>
    (a) #logo (b) #box (c) .star (d) h2
  17. 17.True or false: .card is a class selector. (a) False (b) True
  18. 18.🎯 Can many elements share the same class? (a) Yes (b) No
  19. 19.True or false: the border is the line round the box. (a) True (b) False
  20. 20.🧩 Which language changes the text size? (a) CSS (b) JavaScript (c) HTML
  21. 21.🌈 Which hex code is yellow? (a) #ffffff (b) #ff00ff (c) #00ffff (d) #ffff00
  22. 22.🎯 How many elements on a page should have the same id? (a) 2 (b) any number (c) 1 (d) 5
  23. 23.🌈 In #000057 the blue part is the hex number 57. What is it as a normal number?
  24. 24.⚖️ What colour is the text of this element?
    <h1 class="star" id="top">Hi</h1>
    CSS:
    .star { color: blue; }
    #top { color: green; }
    (a) orange (b) purple (c) blue (d) green
  25. 25.🎯 Which element does the selector .note style? (a) <h2 class="red"> (b) <h1 class="note"> (c) <h1 id="note"> (d) <h1 class="big">
  26. 26.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) black (c) blue (d) red
  27. 27.✍️ Which sign goes between a property and its value? (a) = (b) - (c) ; (d) :
  28. 28.✍️ What is the selector in this CSS rule?
    h1 {
      width: 300px;
      border: 2px solid;
      margin: 10px;
      font-style: italic;
    }
    (a) 2px solid (b) width (c) h1 (d) p
  29. 29.✍️ How many declarations (property: value pairs) are in this rule?
    #top {
      text-align: center;
      color: red;
    }
  30. 30.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 260px;
      justify-content: center;
    }
    Inside are 4 boxes, each 60px wide (no margins).
  31. 31.Which of these is padding? (a) a solid or dotted edge (b) space outside the border (c) the gap to other boxes (d) space inside the border
  32. 32.True or false: JavaScript counts down a timer. (a) True (b) False
  33. 33.📦 In the box model, which part is space outside the border? (a) content (b) border (c) margin (d) padding
  34. 34.Which of these is padding? (a) a solid or dotted edge (b) the gap to other boxes (c) the text or picture (d) the gap round content
  35. 35.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 130px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 60px wide (no margins).
  36. 36.⚖️ Which selector is the weakest? (a) an id selector (b) an element selector (c) a class selector
  37. 37.⚖️ What colour is the text of this element?
    <p class="star" id="end">Hi</p>
    CSS:
    .star { color: orange; }
    p { color: white; }
    #end { color: red; }
    (a) black (b) red (c) orange (d) white
  38. 38.🖌️ What colour is behind the letters?
    h1 {
      font-size: 32px;
      color: purple;
      background-color: white;
      text-align: left;
    }
    (a) green (b) white (c) purple
  39. 39.🎯 What kind of selector is p? (a) a class selector (b) an element selector (c) an id selector
  40. 40.🌈 Which colour is #000000? (a) white (b) black (c) bright green (d) blue

Answer key

  1. h1
  2. False
  3. JavaScript
  4. blue
  5. the text or picture
  6. white
  7. <div class="menu">
  8. black
  9. border
  10. a class selector
  11. 1
  12. False
  13. an id selector
  14. style
  15. blue
  16. #logo
  17. True
  18. Yes
  19. True
  20. CSS
  21. #ffff00
  22. 1
  23. 87
  24. green
  25. <h1 class="note">
  26. red
  27. :
  28. h1
  29. 2
  30. 10
  31. space inside the border
  32. True
  33. margin
  34. the gap round content
  35. 10
  36. an element selector
  37. red
  38. white
  39. an element selector
  40. black

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