← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 679 · 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?
    li {
      color: red;
      width: 300px;
    }
    (a) 300px (b) color (c) body (d) li
  2. 2.🎯 What kind of selector is .card? (a) a class selector (b) an element selector (c) an id selector
  3. 3.✍️ In color: blue; which part is the property? (a) ; (b) color (c) : (d) blue
  4. 4.🌈 Which colour of light is strongest in rgb(158, 26, 136)? (a) red (b) blue (c) green
  5. 5.🎨 One CSS file can style how many pages? (a) no pages (b) many pages (c) only one word (d) only one image
  6. 6.🖌️ What colour is behind the letters?
    li {
      color: black;
      font-size: 12px;
      background-color: blue;
      text-align: left;
    }
    (a) blue (b) red (c) black
  7. 7.✍️ Which property is set to 2px solid in this rule?
    #top {
      border: 2px solid;
      background-color: yellow;
      font-weight: bold;
      width: 300px;
    }
    (a) border (b) width (c) font-style (d) 2px solid
  8. 8.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 160px;
      padding: 20px;
      border: 3px solid black;
      margin: 5px;
    }
  9. 9.⚖️ What colour is the text of this element?
    <h2 class="note" id="intro">Hi</h2>
    CSS:
    h2 { color: blue; }
    h2 { color: red; }
    (a) orange (b) blue (c) black (d) red
  10. 10.🎯 Which element does the selector p style? (a) <h1> (b) <li id="hero"> (c) <p class="star"> (d) <h2 class="star">
  11. 11.True or false: #top is an element selector. (a) True (b) False
  12. 12.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 10px;
      }
    }
  13. 13.⚖️ What colour is the text of this element?
    <h1 class="note" id="end">Hi</h1>
    CSS:
    h1 { color: yellow; }
    h1 { color: green; }
    (a) green (b) yellow (c) red (d) purple
  14. 14.🧩 Which language gives the page structure? (a) CSS (b) HTML (c) JavaScript
  15. 15.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 160px;
      justify-content: flex-end;
    }
    Inside are 3 boxes, each 40px wide (no margins).
  16. 16.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) turned off (c) 600px or wider (d) 600px or narrower
  17. 17.🌈 In #rrggbb, which colour do the last two digits give? (a) blue (b) red (c) green (d) white
  18. 18.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 12px;
      }
    }
  19. 19.🎯 How many elements on a page should have the same id? (a) 5 (b) any number (c) 1 (d) 2
  20. 20.✍️ Which property is set to 300px in this rule?
    #top {
      font-weight: bold;
      width: 300px;
    }
    (a) color (b) 300px (c) width (d) font-style
  21. 21.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 50px;
      padding: 15px;
      border: 3px solid black;
      margin: 20px;
    }
  22. 22.🖌️ Which CSS property sets the letter colour? (a) color (b) font-size (c) text-align (d) background-color
  23. 23.True or false: .big is an element selector. (a) False (b) True
  24. 24.💪 Which flexbox property spaces boxes along a row? (a) flex-direction (b) display: flex (c) justify-content (d) align-items
  25. 25.⚖️ What colour is the text of this element?
    <p class="note" id="hero">Hi</p>
    CSS:
    #hero { color: yellow; }
    .note { color: black; }
    (a) purple (b) black (c) yellow (d) orange
  26. 26.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) exactly 100px (c) 800px or wider (d) 800px or narrower
  27. 27.✍️ What is the selector in this CSS rule?
    .note {
      padding: 8px;
      margin: 10px;
      font-size: 20px;
      background-color: yellow;
    }
    (a) 10px (b) padding (c) #top (d) .note
  28. 28.What does color do? (a) colours behind the text (b) sets the letter colour (c) makes letters bigger (d) makes the text bold
  29. 29.🌈 In #004800 the green part is the hex number 48. What is it as a normal number?
  30. 30.What does justify-content: center do? (a) puts boxes in the middle (b) packs boxes at the end (c) packs boxes at the start (d) equal gaps, none at ends
  31. 31.True or false: CSS makes a form box. (a) True (b) False
  32. 32.✍️ What is the selector in this CSS rule?
    #top {
      margin: 10px;
      text-align: center;
      width: 300px;
      font-style: italic;
    }
    (a) margin (b) #top (c) li (d) center
  33. 33.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 80px;
      padding: 15px;
      border: 5px solid black;
      margin: 10px;
    }
  34. 34.📱 The screen is 700px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 28px;
      }
    }
    (a) No (b) Yes
  35. 35.⚖️ What colour is the text of this element?
    <h1 class="big" id="top">Hi</h1>
    CSS:
    .big { color: white; }
    .big { color: green; }
    (a) orange (b) green (c) blue (d) white
  36. 36.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 18px;
      }
    }
  37. 37.✍️ What value is given to font-style in this rule?
    p {
      font-size: 20px;
      color: red;
      font-style: italic;
    }
    (a) 20px (b) red (c) font-style (d) italic
  38. 38.🌈 Which colour is rgb(0, 0, 255)? (a) blue (b) cyan (c) magenta (d) black
  39. 39.🌈 Which colour is #000000? (a) cyan (b) red (c) white (d) black
  40. 40.🖌️ What colour are the letters?
    p {
      text-align: left;
      font-size: 40px;
      color: yellow;
      background-color: black;
    }
    (a) orange (b) yellow (c) black

Answer key

  1. li
  2. a class selector
  3. color
  4. red
  5. many pages
  6. blue
  7. border
  8. 216
  9. red
  10. <p class="star">
  11. False
  12. 10
  13. green
  14. HTML
  15. 40
  16. 600px or narrower
  17. blue
  18. 12
  19. 1
  20. width
  21. 126
  22. color
  23. False
  24. justify-content
  25. yellow
  26. 800px or wider
  27. .note
  28. sets the letter colour
  29. 72
  30. puts boxes in the middle
  31. False
  32. #top
  33. 140
  34. Yes
  35. green
  36. 16
  37. italic
  38. blue
  39. black
  40. yellow

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