← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 372 · 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 tag holds CSS inside the head? (a) <style> (b) <script> (c) <css> (d) <body>
  2. 2.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      margin: 10px;
      font-size: 20px;
      background-color: yellow;
    }
  3. 3.💪 Which flexbox property lines boxes up across? (a) display: flex (b) flex-direction (c) justify-content (d) align-items
  4. 4.🖌️ Where does the text sit on its line?
    h1 {
      background-color: red;
      color: white;
      font-size: 24px;
      text-align: center;
    }
    (a) on the left (b) on the right (c) in the middle
  5. 5.🧩 Which language adds space around boxes? (a) CSS (b) JavaScript (c) HTML
  6. 6.⚖️ What colour is the text of this element?
    <h2 class="star" id="top">Hi</h2>
    CSS:
    .star { color: red; }
    #top { color: purple; }
    (a) black (b) purple (c) green (d) red
  7. 7.✍️ How many declarations (property: value pairs) are in this rule?
    #top {
      font-size: 20px;
      font-weight: bold;
    }
  8. 8.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 6 (b) 3 (c) 4 (d) 2
  9. 9.⚖️ What colour is the text of this element?
    <p class="red" id="intro">Hi</p>
    CSS:
    #intro { color: blue; }
    #intro { color: red; }
    (a) orange (b) blue (c) red (d) purple
  10. 10.🎯 Which element does the selector #hero style? (a) <h2 id="hero"> (b) <h2 id="top"> (c) <li class="star"> (d) <h2 class="hero">
  11. 11.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 300px;
      justify-content: flex-start;
    }
    Inside are 3 boxes, each 80px wide (no margins).
  12. 12.🎯 Which sign starts an id selector? (a) . (b) & (c) # (d) @
  13. 13.📱 max-width: 600px applies when the screen is ___. (a) turned off (b) 600px or wider (c) exactly 1000px (d) 600px or narrower
  14. 14.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      font-size: 20px;
    }
  15. 15.🌈 Which colour is #ff00ff? (a) white (b) magenta (c) yellow (d) black
  16. 16.⚖️ What colour is the text of this element?
    <h2 class="star" id="top">Hi</h2>
    CSS:
    h2 { color: green; }
    h2 { color: blue; }
    (a) yellow (b) black (c) green (d) blue
  17. 17.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 380px;
      justify-content: center;
    }
    Inside are 3 boxes, each 100px wide (no margins).
  18. 18.🧩 Which language reacts to a button click? (a) HTML (b) CSS (c) JavaScript
  19. 19.🌈 Which hex code is red? (a) #00ff00 (b) #ffffff (c) #ff0000 (d) #000000
  20. 20.⚖️ What colour is the text of this element?
    <p class="red" id="top">Hi</p>
    CSS:
    #top { color: green; }
    p { color: white; }
    (a) white (b) black (c) green (d) purple
  21. 21.📱 The screen is 540px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 14px;
      }
    }
    (a) Yes (b) No
  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: 26px;
      }
    }
  23. 23.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 280px;
      padding: 25px;
      border: 5px solid black;
      margin: 20px;
    }
  24. 24.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 180px;
      justify-content: flex-end;
    }
    Inside are 4 boxes, each 40px wide (no margins).
  25. 25.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
  26. 26.🎯 Which element does the selector #main style? (a) <p class="main"> (b) <p id="main"> (c) <p id="logo"> (d) <h1 class="big">
  27. 27.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 22px;
      }
    }
  28. 28.🔍 Which is the odd one out? (a) reacts to a button click (b) changes the page live (c) checks a quiz answer (d) puts a picture on a page
  29. 29.⚖️ What colour is the text of this element?
    <h1 class="red" id="end">Hi</h1>
    CSS:
    #end { color: yellow; }
    #end { color: blue; }
    (a) yellow (b) red (c) black (d) blue
  30. 30.🖌️ What colour are the letters?
    li {
      color: white;
      font-size: 20px;
      background-color: black;
      text-align: left;
    }
    (a) blue (b) white (c) black
  31. 31.💪 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).
  32. 32.🌈 Which colour of light is strongest in rgb(4, 161, 124)? (a) green (b) red (c) blue
  33. 33.🖌️ Where does the text sit on its line?
    h2 {
      font-size: 24px;
      color: blue;
      background-color: red;
      text-align: right;
    }
    (a) on the left (b) in the middle (c) on the right
  34. 34.✍️ What value is given to font-size in this rule?
    p {
      font-style: italic;
      font-size: 20px;
      color: red;
    }
    (a) font-size (b) 20px (c) center (d) yellow
  35. 35.🔍 Which is the odd one out? (a) gives the page structure (b) reacts to a button click (c) checks a quiz answer (d) counts down a timer
  36. 36.🖌️ Where does the text sit on its line?
    p {
      background-color: black;
      font-size: 16px;
      text-align: center;
      color: white;
    }
    (a) on the left (b) on the right (c) in the middle
  37. 37.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 160px;
      justify-content: space-between;
    }
    Inside are 2 boxes, each 60px wide (no margins).
  38. 38.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 220px;
      justify-content: center;
    }
    Inside are 3 boxes, each 60px wide (no margins).
  39. 39.What does justify-content: flex-end do? (a) equal gaps, none at ends (b) packs boxes at the end (c) packs boxes at the start (d) puts boxes in the middle
  40. 40.🖌️ What colour are the letters?
    li {
      background-color: red;
      text-align: center;
      font-size: 32px;
      color: blue;
    }
    (a) blue (b) red (c) black

Answer key

  1. <style>
  2. 3
  3. align-items
  4. in the middle
  5. CSS
  6. purple
  7. 2
  8. 3
  9. red
  10. <h2 id="hero">
  11. 60
  12. #
  13. 600px or narrower
  14. 1
  15. magenta
  16. blue
  17. 40
  18. JavaScript
  19. #ff0000
  20. green
  21. No
  22. 20
  23. 380
  24. 20
  25. an element selector
  26. <p id="main">
  27. 16
  28. puts a picture on a page
  29. blue
  30. white
  31. 30
  32. green
  33. on the right
  34. 20px
  35. gives the page structure
  36. in the middle
  37. 40
  38. 20
  39. packs boxes at the end
  40. blue

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