← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 221 · 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 selector matches this element?
    <h1 class="big" id="intro">Hello</h1>
    (a) .intro (b) #main (c) h1 (d) .red
  2. 2.🖌️ What colour is behind the letters?
    h1 {
      color: red;
      text-align: left;
      background-color: purple;
      font-size: 28px;
    }
    (a) purple (b) yellow (c) red
  3. 3.🎯 Which element does the selector p style? (a) <h1> (b) <h2 class="red"> (c) <p class="red"> (d) <li id="end">
  4. 4.📱 Responsive design means a page ___. (a) never changes (b) is only for laptops (c) has no pictures (d) fits every screen
  5. 5.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 260px;
      justify-content: center;
    }
    Inside are 2 boxes, each 60px wide (no margins).
  6. 6.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) white (c) red (d) blue
  7. 7.🎯 Which element does the selector #logo style? (a) <h2 id="end"> (b) <h2 id="logo"> (c) <li class="big"> (d) <h2 class="logo">
  8. 8.⚖️ What colour is the text of this element?
    <h2 class="big" id="main">Hi</h2>
    CSS:
    #main { color: red; }
    h2 { color: green; }
    .big { color: white; }
    (a) green (b) white (c) red (d) black
  9. 9.🖌️ Which CSS property picks the font style? (a) color (b) font-size (c) background-color (d) font-family
  10. 10.✍️ In color: blue; which part is the property? (a) ; (b) blue (c) color (d) :
  11. 11.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 24px;
      }
    }
  12. 12.🖌️ How big is the text, in px?
    h2 {
      color: red;
      background-color: black;
      font-size: 28px;
      text-align: right;
    }
  13. 13.🎯 What kind of selector is #main? (a) a class selector (b) an element selector (c) an id selector
  14. 14.💪 Which justify-content value packs boxes at the start? (a) flex-start (b) center (c) flex-end (d) space-between
  15. 15.What does color do? (a) picks the font style (b) colours behind the text (c) makes letters bigger (d) sets the letter colour
  16. 16.✍️ What is the selector in this CSS rule?
    #top {
      margin: 10px;
      color: red;
      text-align: center;
    }
    (a) margin (b) red (c) li (d) #top
  17. 17.✍️ What is the selector in this CSS rule?
    .note {
      font-style: italic;
      border: 2px solid;
      font-weight: bold;
      font-size: 20px;
    }
    (a) #top (b) font-style (c) 2px solid (d) .note
  18. 18.What does justify-content: center do? (a) equal gaps, none at ends (b) packs boxes at the start (c) puts boxes in the middle (d) packs boxes at the end
  19. 19.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
  20. 20.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 18px;
      }
    }
  21. 21.🌈 Which colour is #ff0000? (a) cyan (b) bright green (c) blue (d) red
  22. 22.📱 max-width: 600px applies when the screen is ___. (a) 600px or narrower (b) exactly 1000px (c) 600px or wider (d) turned off
  23. 23.True or false: HTML rounds box corners. (a) True (b) False
  24. 24.✍️ Which sign goes between a property and its value? (a) = (b) ; (c) - (d) :
  25. 25.⚖️ What colour is the text of this element?
    <p class="box" id="top">Hi</p>
    CSS:
    #top { color: green; }
    #top { color: yellow; }
    (a) black (b) green (c) orange (d) yellow
  26. 26.⚖️ What colour is the text of this element?
    <h1 class="red" id="end">Hi</h1>
    CSS:
    h1 { color: purple; }
    h1 { color: yellow; }
    (a) black (b) blue (c) purple (d) yellow
  27. 27.True or false: HTML puts a picture on a page. (a) False (b) True
  28. 28.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 200px;
      padding: 20px;
      border: 5px solid black;
      margin: 15px;
    }
  29. 29.✍️ How does a CSS comment start? (a) <!-- (b) // (c) /* (d) #
  30. 30.Which of these does JavaScript do? (a) reacts to a button click (b) makes a link (c) lays out the page (d) gives the page structure
  31. 31.🌈 Which colour is rgb(255, 255, 255)? (a) blue (b) white (c) red (d) bright green
  32. 32.True or false: #logo is a class selector. (a) False (b) True
  33. 33.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 170px;
      justify-content: flex-end;
    }
    Inside are 3 boxes, each 50px wide (no margins).
  34. 34.📦 In the box model, which part is a solid or dotted edge? (a) border (b) margin (c) padding (d) content
  35. 35.🌈 Which colour is rgb(255, 0, 255)? (a) black (b) white (c) cyan (d) magenta
  36. 36.💪 Which flexbox property spaces boxes along a row? (a) justify-content (b) display: flex (c) gap (d) align-items
  37. 37.🧩 Which language adds space around boxes? (a) JavaScript (b) HTML (c) CSS
  38. 38.What does justify-content: flex-start do? (a) equal gaps, none at ends (b) packs boxes at the start (c) packs boxes at the end (d) puts boxes in the middle
  39. 39.🎯 Which sign starts an id selector? (a) & (b) . (c) # (d) @
  40. 40.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 190px;
      padding: 10px;
      border: 1px solid black;
      margin: 0px;
    }

Answer key

  1. h1
  2. purple
  3. <p class="red">
  4. fits every screen
  5. 70
  6. blue
  7. <h2 id="logo">
  8. red
  9. font-family
  10. color
  11. 20
  12. 28
  13. an id selector
  14. flex-start
  15. sets the letter colour
  16. #top
  17. .note
  18. puts boxes in the middle
  19. an element selector
  20. 16
  21. red
  22. 600px or narrower
  23. False
  24. :
  25. yellow
  26. yellow
  27. True
  28. 280
  29. /*
  30. reacts to a button click
  31. white
  32. False
  33. 20
  34. border
  35. magenta
  36. justify-content
  37. CSS
  38. packs boxes at the start
  39. #
  40. 212

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