← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 856 · 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.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 24px;
      }
    }
  2. 2.💪 Which flexbox property turns on flexbox? (a) gap (b) flex-direction (c) justify-content (d) display: flex
  3. 3.📱 The screen is 375px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 20px;
      }
    }
    (a) No (b) Yes
  4. 4.⚖️ What colour is the text of this element?
    <h2 class="red" id="main">Hi</h2>
    CSS:
    h2 { color: white; }
    h2 { color: red; }
    (a) red (b) yellow (c) purple (d) white
  5. 5.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the later one (c) the first one (d) neither
  6. 6.🖌️ Where does the text sit on its line?
    p {
      font-size: 24px;
      color: white;
      background-color: yellow;
      text-align: left;
    }
    (a) on the left (b) on the right (c) in the middle
  7. 7.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 290px;
      padding: 10px;
      border: 1px solid black;
      margin: 10px;
    }
  8. 8.🖌️ Which CSS property makes the text bold? (a) font-weight (b) font-family (c) background-color (d) font-size
  9. 9.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 250px;
      padding: 5px;
      border: 4px solid black;
      margin: 20px;
    }
  10. 10.💪 Which flexbox property sets space between boxes? (a) gap (b) display: flex (c) justify-content (d) flex-direction
  11. 11.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 24px;
      }
    }
  12. 12.🌈 Which colour is rgb(0, 255, 0)? (a) red (b) blue (c) magenta (d) bright green
  13. 13.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 280px;
      justify-content: flex-end;
    }
    Inside are 2 boxes, each 100px wide (no margins).
  14. 14.🎯 Which element does the selector .star style? (a) <li class="note"> (b) <h2 class="star"> (c) <h2 class="menu"> (d) <h2 id="star">
  15. 15.✍️ What is the selector in this CSS rule?
    #top {
      padding: 8px;
      border: 2px solid;
      text-align: center;
    }
    (a) li (b) 2px solid (c) #top (d) padding
  16. 16.⚖️ What colour is the text of this element?
    <p class="menu" id="hero">Hi</p>
    CSS:
    p { color: white; }
    p { color: purple; }
    (a) purple (b) green (c) blue (d) white
  17. 17.✍️ Which property is set to 20px in this rule?
    body {
      font-size: 20px;
      border: 2px solid;
    }
    (a) background-color (b) 20px (c) text-align (d) font-size
  18. 18.🎯 Which CSS selector matches this element?
    <li class="box" id="hero">Hello</li>
    (a) .hero (b) div (c) li (d) #box
  19. 19.⚖️ What colour is the text of this element?
    <h2 class="big" id="intro">Hi</h2>
    CSS:
    #intro { color: red; }
    #intro { color: yellow; }
    (a) blue (b) purple (c) yellow (d) red
  20. 20.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 8px;
      }
    }
  21. 21.🎯 Which element does the selector .red style? (a) <h2 class="box"> (b) <li class="star"> (c) <h2 class="red"> (d) <h2 id="red">
  22. 22.🎨 Which tag holds CSS inside the head? (a) <style> (b) <script> (c) <body> (d) <css>
  23. 23.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 20px;
      }
    }
  24. 24.🖌️ Where does the text sit on its line?
    p {
      background-color: red;
      font-size: 12px;
      text-align: left;
      color: white;
    }
    (a) in the middle (b) on the left (c) on the right
  25. 25.🔍 Which is the odd one out? (a) counts down a timer (b) rounds box corners (c) shows a pop-up message (d) checks a quiz answer
  26. 26.🎯 What kind of selector is .star? (a) an element selector (b) a class selector (c) an id selector
  27. 27.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 190px;
      justify-content: flex-end;
    }
    Inside are 4 boxes, each 40px wide (no margins).
  28. 28.True or false: HTML counts down a timer. (a) False (b) True
  29. 29.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 10px;
      }
    }
  30. 30.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 170px;
      padding: 10px;
      border: 5px solid black;
      margin: 20px;
    }
  31. 31.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
  32. 32.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 14px;
      }
    }
  33. 33.📱 The screen is 700px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 10px;
      }
    }
    (a) Yes (b) No
  34. 34.What does font-family do? (a) centres a heading (b) makes the text bold (c) makes letters bigger (d) picks the font style
  35. 35.True or false: HTML puts a picture on a page. (a) True (b) False
  36. 36.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 120px;
      padding: 10px;
      border: 4px solid black;
      margin: 20px;
    }
  37. 37.🎯 Which element does the selector .big style? (a) <p class="red"> (b) <h1 class="box"> (c) <p id="big"> (d) <p class="big">
  38. 38.✍️ What value is given to background-color in this rule?
    #top {
      background-color: yellow;
      border: 2px solid;
      width: 300px;
      font-size: 20px;
    }
    (a) 8px (b) background-color (c) 10px (d) yellow
  39. 39.✍️ Which property is set to red in this rule?
    p {
      text-align: center;
      color: red;
      padding: 8px;
    }
    (a) color (b) text-align (c) font-size (d) red
  40. 40.🖌️ Which CSS property centres a heading? (a) font-size (b) text-align (c) color (d) font-family

Answer key

  1. 20
  2. display: flex
  3. Yes
  4. red
  5. the later one
  6. on the left
  7. 332
  8. font-weight
  9. 308
  10. gap
  11. 20
  12. bright green
  13. 80
  14. <h2 class="star">
  15. #top
  16. purple
  17. font-size
  18. li
  19. yellow
  20. 12
  21. <h2 class="red">
  22. <style>
  23. 20
  24. on the left
  25. rounds box corners
  26. a class selector
  27. 30
  28. False
  29. 12
  30. 240
  31. an id selector
  32. 16
  33. Yes
  34. picks the font style
  35. True
  36. 148
  37. <p class="big">
  38. yellow
  39. color
  40. text-align

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