← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 102 · 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.True or false: li is an element selector. (a) True (b) False
  2. 2.🌈 What is the biggest number one colour can have in rgb()? (a) 1000 (b) 100 (c) 255 (d) 99
  3. 3.🎯 Which element does the selector .big style? (a) <li class="big"> (b) <li id="big"> (c) <li class="red"> (d) <div class="box">
  4. 4.🧩 Which language gives the page structure? (a) CSS (b) JavaScript (c) HTML
  5. 5.True or false: the border is the line round the box. (a) False (b) True
  6. 6.🖌️ Which CSS property sets the letter colour? (a) background-color (b) color (c) font-size (d) font-weight
  7. 7.⚖️ What colour is the text of this element?
    <h2 class="box" id="end">Hi</h2>
    CSS:
    .box { color: orange; }
    h2 { color: yellow; }
    (a) black (b) orange (c) yellow (d) red
  8. 8.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the first one (c) the later one (d) the shorter one
  9. 9.True or false: .big is a class selector. (a) True (b) False
  10. 10.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      border: 2px solid;
      width: 300px;
      padding: 8px;
    }
  11. 11.🎯 Which element does the selector .big style? (a) <div id="big"> (b) <div class="big"> (c) <div class="red"> (d) <span class="box">
  12. 12.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      background-color: yellow;
      margin: 10px;
      font-style: italic;
      text-align: center;
    }
  13. 13.What does justify-content: flex-end do? (a) packs boxes at the end (b) equal gaps, none at ends (c) packs boxes at the start (d) puts boxes in the middle
  14. 14.🖌️ How big is the text, in px?
    h1 {
      background-color: orange;
      text-align: left;
      font-size: 36px;
      color: red;
    }
  15. 15.Which of these is padding? (a) space outside the border (b) a solid or dotted edge (c) the text or picture (d) space inside the border
  16. 16.🖌️ How big is the text, in px?
    h1 {
      text-align: center;
      font-size: 28px;
      background-color: purple;
      color: white;
    }
  17. 17.✍️ CSS declarations go inside which brackets? (a) { } (b) < > (c) [ ] (d) ( )
  18. 18.🖌️ What colour is behind the letters?
    li {
      text-align: center;
      background-color: green;
      font-size: 24px;
      color: white;
    }
    (a) green (b) white (c) yellow
  19. 19.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 18px;
      }
    }
  20. 20.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
  21. 21.⚖️ What colour is the text of this element?
    <p class="menu" id="top">Hi</p>
    CSS:
    #top { color: black; }
    .menu { color: white; }
    (a) black (b) white (c) orange (d) green
  22. 22.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 24px;
      }
    }
  23. 23.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 120px;
      justify-content: space-between;
    }
    Inside are 2 boxes, each 40px wide (no margins).
  24. 24.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 170px;
      padding: 10px;
      border: 5px solid black;
      margin: 20px;
    }
  25. 25.🔍 Which is the odd one out? (a) counts down a timer (b) puts a picture on a page (c) makes headings and lists (d) makes a link
  26. 26.💪 Which flexbox property sets space between boxes? (a) align-items (b) display: flex (c) gap (d) flex-direction
  27. 27.💪 Which flexbox property picks row or column? (a) justify-content (b) display: flex (c) align-items (d) flex-direction
  28. 28.What does justify-content: space-between do? (a) packs boxes at the start (b) packs boxes at the end (c) equal gaps, none at ends (d) puts boxes in the middle
  29. 29.✍️ Which property is set to 300px in this rule?
    h1 {
      width: 300px;
      color: red;
      font-size: 20px;
    }
    (a) 300px (b) color (c) font-style (d) width
  30. 30.What does color do? (a) colours behind the text (b) sets the letter colour (c) centres a heading (d) makes letters bigger
  31. 31.💪 Which justify-content value packs boxes at the start? (a) space-between (b) flex-end (c) flex-start (d) center
  32. 32.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 8px;
      }
    }
  33. 33.🎯 What kind of selector is #main? (a) a class selector (b) an element selector (c) an id selector
  34. 34.🖌️ What colour are the letters?
    h1 {
      background-color: red;
      text-align: left;
      color: orange;
      font-size: 12px;
    }
    (a) red (b) purple (c) orange
  35. 35.⚖️ What colour is the text of this element?
    <p class="box" id="top">Hi</p>
    CSS:
    p { color: blue; }
    p { color: white; }
    (a) blue (b) red (c) purple (d) white
  36. 36.⚖️ What colour is the text of this element?
    <h1 class="star" id="logo">Hi</h1>
    CSS:
    #logo { color: blue; }
    #logo { color: red; }
    (a) yellow (b) orange (c) red (d) blue
  37. 37.True or false: .menu is an id selector. (a) True (b) False
  38. 38.⚖️ What colour is the text of this element?
    <p class="red" id="top">Hi</p>
    CSS:
    .red { color: blue; }
    p { color: orange; }
    #top { color: yellow; }
    (a) blue (b) yellow (c) orange (d) red
  39. 39.✍️ What is the selector in this CSS rule?
    p {
      text-align: center;
      padding: 8px;
    }
    (a) text-align (b) 8px (c) .note (d) p
  40. 40.💪 Which flexbox property turns on flexbox? (a) flex-direction (b) align-items (c) gap (d) display: flex

Answer key

  1. True
  2. 255
  3. <li class="big">
  4. HTML
  5. True
  6. color
  7. orange
  8. the later one
  9. True
  10. 3
  11. <div class="big">
  12. 4
  13. packs boxes at the end
  14. 36
  15. space inside the border
  16. 28
  17. { }
  18. green
  19. 20
  20. an id selector
  21. black
  22. 20
  23. 40
  24. 200
  25. counts down a timer
  26. gap
  27. flex-direction
  28. equal gaps, none at ends
  29. width
  30. sets the letter colour
  31. flex-start
  32. 8
  33. an id selector
  34. orange
  35. white
  36. red
  37. False
  38. yellow
  39. p
  40. display: flex

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