← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 224 · 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 value is given to font-size in this rule?
    h2 {
      text-align: center;
      font-size: 20px;
      border: 2px solid;
      width: 300px;
    }
    (a) yellow (b) font-size (c) 20px (d) center
  2. 2.💪 Which flexbox property turns on flexbox? (a) justify-content (b) flex-direction (c) display: flex (d) align-items
  3. 3.🌈 Which colour of light is strongest in rgb(18, 164, 78)? (a) red (b) green (c) blue
  4. 4.What does background-color do? (a) colours behind the text (b) picks the font style (c) sets the letter colour (d) makes the text bold
  5. 5.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 270px;
      padding: 25px;
      border: 2px solid black;
      margin: 5px;
    }
  6. 6.🖌️ What colour is behind the letters?
    li {
      font-size: 36px;
      color: blue;
      background-color: purple;
      text-align: left;
    }
    (a) red (b) blue (c) purple
  7. 7.🧩 Which language reacts to a button click? (a) CSS (b) HTML (c) JavaScript
  8. 8.✍️ What value is given to background-color in this rule?
    #top {
      font-style: italic;
      background-color: yellow;
    }
    (a) 8px (b) background-color (c) yellow (d) 10px
  9. 9.🖌️ Where does the text sit on its line?
    li {
      font-size: 36px;
      background-color: black;
      text-align: center;
      color: purple;
    }
    (a) on the left (b) on the right (c) in the middle
  10. 10.🎯 What kind of selector is body? (a) a class selector (b) an id selector (c) an element selector
  11. 11.💪 Which justify-content value packs boxes at the start? (a) flex-start (b) center (c) space-between (d) flex-end
  12. 12.🖌️ Where does the text sit on its line?
    li {
      font-size: 32px;
      text-align: center;
      color: blue;
      background-color: yellow;
    }
    (a) on the right (b) in the middle (c) on the left
  13. 13.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the later one (b) the first one (c) neither (d) the shorter one
  14. 14.🖌️ Which CSS property picks the font style? (a) background-color (b) color (c) font-weight (d) font-family
  15. 15.🎨 What does CSS stand for? (a) Computer Style Sheets (b) Colourful Site Styles (c) Creative Sheet System (d) Cascading Style Sheets
  16. 16.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) turned off (c) exactly 1000px (d) 600px or narrower
  17. 17.📦 In the box model, which part is the gap to other boxes? (a) padding (b) margin (c) border (d) content
  18. 18.🎯 Which element does the selector .box style? (a) <div id="box"> (b) <span class="menu"> (c) <div class="star"> (d) <div class="box">
  19. 19.🖌️ Where does the text sit on its line?
    h2 {
      text-align: center;
      background-color: black;
      color: green;
      font-size: 12px;
    }
    (a) in the middle (b) on the left (c) on the right
  20. 20.💪 Which flexbox property spaces boxes along a row? (a) flex-direction (b) justify-content (c) display: flex (d) gap
  21. 21.✍️ What value is given to border in this rule?
    h1 {
      border: 2px solid;
      width: 300px;
      text-align: center;
    }
    (a) 2px solid (b) 300px (c) border (d) italic
  22. 22.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 110px;
      padding: 20px;
      border: 4px solid black;
      margin: 0px;
    }
  23. 23.💪 Which flexbox property lines boxes up across? (a) display: flex (b) justify-content (c) align-items (d) flex-direction
  24. 24.🎨 Which attribute adds CSS inside one tag? (a) src (b) alt (c) href (d) style
  25. 25.What does text-align do? (a) makes the text bold (b) centres a heading (c) sets the letter colour (d) makes letters bigger
  26. 26.True or false: JavaScript reacts to a button click. (a) False (b) True
  27. 27.True or false: padding is space outside the border. (a) True (b) False
  28. 28.⚖️ What colour is the text of this element?
    <p class="big" id="top">Hi</p>
    CSS:
    #top { color: blue; }
    .big { color: green; }
    p { color: black; }
    (a) black (b) blue (c) green (d) orange
  29. 29.True or false: the border is the line round the box. (a) False (b) True
  30. 30.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 12px;
      }
    }
  31. 31.True or false: padding is the gap round content. (a) False (b) True
  32. 32.True or false: #main is an id selector. (a) True (b) False
  33. 33.🎯 Which CSS selector matches this element?
    <p class="box" id="end">Hello</p>
    (a) h1 (b) #box (c) #hero (d) p
  34. 34.✍️ How many declarations (property: value pairs) are in this rule?
    li {
      color: red;
      width: 300px;
      font-weight: bold;
    }
  35. 35.⚖️ What colour is the text of this element?
    <h2 class="box" id="end">Hi</h2>
    CSS:
    h2 { color: green; }
    h2 { color: white; }
    (a) yellow (b) black (c) white (d) green
  36. 36.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 22px;
      }
    }
  37. 37.⚖️ What colour is the text of this element?
    <p class="note" id="main">Hi</p>
    CSS:
    #main { color: red; }
    #main { color: green; }
    (a) yellow (b) red (c) white (d) green
  38. 38.🎯 Which element does the selector h2 style? (a) <li> (b) <span id="top"> (c) <div class="star"> (d) <h2 class="star">
  39. 39.True or false: margin is the gap round content. (a) True (b) False
  40. 40.📦 In the box model, which part is the line round the box? (a) content (b) margin (c) padding (d) border

Answer key

  1. 20px
  2. display: flex
  3. green
  4. colours behind the text
  5. 324
  6. purple
  7. JavaScript
  8. yellow
  9. in the middle
  10. an element selector
  11. flex-start
  12. in the middle
  13. the later one
  14. font-family
  15. Cascading Style Sheets
  16. 600px or narrower
  17. margin
  18. <div class="box">
  19. in the middle
  20. justify-content
  21. 2px solid
  22. 158
  23. align-items
  24. style
  25. centres a heading
  26. True
  27. False
  28. blue
  29. True
  30. 16
  31. True
  32. True
  33. p
  34. 3
  35. white
  36. 22
  37. green
  38. <h2 class="star">
  39. False
  40. border

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