← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 489 · 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 CSS property centres a heading? (a) text-align (b) font-weight (c) background-color (d) color
  2. 2.✍️ What value is given to padding in this rule?
    h2 {
      padding: 8px;
      background-color: yellow;
      font-size: 20px;
      text-align: center;
    }
    (a) padding (b) bold (c) 2px solid (d) 8px
  3. 3.🎯 Which element does the selector #logo style? (a) <div class="logo"> (b) <div id="logo"> (c) <div id="end"> (d) <span class="box">
  4. 4.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 16px;
      }
    }
  5. 5.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 240px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 100px wide (no margins).
  6. 6.⚖️ What colour is the text of this element?
    <h1 class="box" id="top">Hi</h1>
    CSS:
    h1 { color: red; }
    h1 { color: green; }
    (a) green (b) blue (c) red (d) black
  7. 7.✍️ What value is given to color in this rule?
    p {
      margin: 10px;
      background-color: yellow;
      color: red;
    }
    (a) center (b) color (c) 20px (d) red
  8. 8.💪 Which justify-content value packs boxes at the start? (a) space-between (b) flex-start (c) center (d) flex-end
  9. 9.🖌️ What colour is behind the letters?
    h1 {
      text-align: center;
      background-color: black;
      color: red;
      font-size: 24px;
    }
    (a) black (b) red (c) yellow
  10. 10.🖌️ What colour are the letters?
    li {
      font-size: 12px;
      text-align: left;
      background-color: green;
      color: black;
    }
    (a) green (b) black (c) yellow
  11. 11.🎯 Which CSS selector matches this element?
    <h2 class="red" id="main">Hello</h2>
    (a) .main (b) #logo (c) #main (d) #red
  12. 12.🌈 Which colour is rgb(0, 255, 255)? (a) white (b) cyan (c) yellow (d) magenta
  13. 13.🎨 Which tag connects an outside CSS file? (a) <link> (b) <css> (c) <a> (d) <img>
  14. 14.✍️ What value is given to color in this rule?
    body {
      font-size: 20px;
      color: red;
      font-weight: bold;
    }
    (a) 20px (b) center (c) red (d) color
  15. 15.True or false: the border is the gap to other boxes. (a) False (b) True
  16. 16.True or false: JavaScript checks a quiz answer. (a) True (b) False
  17. 17.🖌️ What colour are the letters?
    p {
      text-align: right;
      background-color: purple;
      color: white;
      font-size: 28px;
    }
    (a) purple (b) white (c) red
  18. 18.🎯 Which element does the selector #logo style? (a) <div class="box"> (b) <li id="logo"> (c) <li class="logo"> (d) <li id="end">
  19. 19.🖌️ How big is the text, in px?
    h2 {
      text-align: left;
      color: black;
      background-color: green;
      font-size: 20px;
    }
  20. 20.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      background-color: yellow;
      width: 300px;
      font-weight: bold;
      font-size: 20px;
    }
  21. 21.🌈 Which colour is #ff00ff? (a) red (b) yellow (c) blue (d) magenta
  22. 22.What does background-color do? (a) sets the letter colour (b) colours behind the text (c) makes letters bigger (d) centres a heading
  23. 23.✍️ CSS declarations go inside which brackets? (a) ( ) (b) [ ] (c) < > (d) { }
  24. 24.⚖️ Which selector is the weakest? (a) an id selector (b) an element selector (c) a class selector
  25. 25.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
  26. 26.💪 Which flexbox property turns on flexbox? (a) flex-direction (b) justify-content (c) display: flex (d) gap
  27. 27.🧩 Which language rounds box corners? (a) JavaScript (b) CSS (c) HTML
  28. 28.🎯 Which CSS selector matches this element?
    <div class="note" id="logo">Hello</div>
    (a) #logo (b) .big (c) #note (d) .logo
  29. 29.Which of these is margin? (a) the line round the box (b) the gap round content (c) a solid or dotted edge (d) space outside the border
  30. 30.🧩 Which language gives the page structure? (a) JavaScript (b) CSS (c) HTML
  31. 31.🌈 In #rrggbb, which colour do the last two digits give? (a) red (b) green (c) blue (d) white
  32. 32.🎯 Which element does the selector .note style? (a) <li class="big"> (b) <li id="note"> (c) <li class="note"> (d) <div class="red">
  33. 33.⚖️ What colour is the text of this element?
    <p class="star" id="logo">Hi</p>
    CSS:
    p { color: orange; }
    p { color: red; }
    (a) orange (b) red (c) white (d) blue
  34. 34.✍️ What is the selector in this CSS rule?
    .box {
      font-size: 20px;
      border: 2px solid;
      background-color: yellow;
    }
    (a) 2px solid (b) h2 (c) .box (d) font-size
  35. 35.🧩 Which language makes a link? (a) HTML (b) CSS (c) JavaScript
  36. 36.✍️ What is the selector in this CSS rule?
    .box {
      width: 300px;
      color: red;
      font-style: italic;
    }
    (a) h2 (b) width (c) red (d) .box
  37. 37.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 160px;
      padding: 25px;
      border: 4px solid black;
      margin: 20px;
    }
  38. 38.🔍 Which is the odd one out? (a) changes the text size (b) makes a link (c) rounds box corners (d) sets colours and fonts
  39. 39.🌈 Which colour is rgb(255, 0, 255)? (a) blue (b) magenta (c) cyan (d) bright green
  40. 40.✍️ What value is given to margin in this rule?
    li {
      margin: 10px;
      background-color: yellow;
    }
    (a) 8px (b) margin (c) bold (d) 10px

Answer key

  1. text-align
  2. 8px
  3. <div id="logo">
  4. 12
  5. 40
  6. green
  7. red
  8. flex-start
  9. black
  10. black
  11. #main
  12. cyan
  13. <link>
  14. red
  15. False
  16. True
  17. white
  18. <li id="logo">
  19. 20
  20. 4
  21. magenta
  22. colours behind the text
  23. { }
  24. an element selector
  25. an id selector
  26. display: flex
  27. CSS
  28. #logo
  29. space outside the border
  30. HTML
  31. blue
  32. <li class="note">
  33. red
  34. .box
  35. HTML
  36. .box
  37. 258
  38. makes a link
  39. magenta
  40. 10px

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