← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 943 · 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 colour is the text of this element?
    <h1 class="red" id="hero">Hi</h1>
    CSS:
    #hero { color: red; }
    #hero { color: white; }
    (a) white (b) blue (c) purple (d) red
  2. 2.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 20px;
      }
    }
  3. 3.🔍 Which is the odd one out? (a) counts down a timer (b) shows a pop-up message (c) sets colours and fonts (d) checks a quiz answer
  4. 4.📱 The screen is 820px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 22px;
      }
    }
    (a) No (b) Yes
  5. 5.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) 800px or wider (c) exactly 100px (d) 800px or narrower
  6. 6.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
  7. 7.True or false: CSS counts down a timer. (a) False (b) True
  8. 8.🌈 Which colour is rgb(255, 255, 0)? (a) yellow (b) cyan (c) bright green (d) red
  9. 9.📱 Which tag helps phones show a page at the right size? (a) the hr tag (b) the title tag (c) the br tag (d) the viewport meta tag
  10. 10.⚖️ What colour is the text of this element?
    <p class="big" id="intro">Hi</p>
    CSS:
    .big { color: red; }
    #intro { color: green; }
    p { color: blue; }
    (a) purple (b) green (c) blue (d) red
  11. 11.⚖️ What colour is the text of this element?
    <h2 class="star" id="hero">Hi</h2>
    CSS:
    #hero { color: blue; }
    #hero { color: red; }
    (a) red (b) yellow (c) blue (d) white
  12. 12.🖌️ Which CSS property centres a heading? (a) color (b) font-size (c) font-weight (d) text-align
  13. 13.✍️ Which property is set to 300px in this rule?
    h2 {
      width: 300px;
      font-size: 20px;
    }
    (a) font-style (b) color (c) width (d) 300px
  14. 14.🌈 Which hex code is red? (a) #ff0000 (b) #0000ff (c) #00ffff (d) #00ff00
  15. 15.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 40px;
      padding: 25px;
      border: 1px solid black;
      margin: 0px;
    }
  16. 16.🖌️ What colour are the letters?
    h1 {
      text-align: right;
      background-color: white;
      font-size: 32px;
      color: purple;
    }
    (a) yellow (b) white (c) purple
  17. 17.🌈 Which colour is rgb(0, 255, 0)? (a) white (b) red (c) blue (d) bright green
  18. 18.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 170px;
      padding: 15px;
      border: 2px solid black;
      margin: 15px;
    }
  19. 19.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 240px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 100px wide (no margins).
  20. 20.🌈 Which hex code is black? (a) #00ff00 (b) #ff0000 (c) #000000 (d) #ffffff
  21. 21.⚖️ What colour is the text of this element?
    <p class="note" id="intro">Hi</p>
    CSS:
    #intro { color: black; }
    #intro { color: yellow; }
    (a) purple (b) black (c) yellow (d) green
  22. 22.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 14px;
      }
    }
  23. 23.🌈 Which colour is rgb(255, 0, 255)? (a) red (b) magenta (c) white (d) bright green
  24. 24.💪 Which flexbox property spaces boxes along a row? (a) display: flex (b) gap (c) align-items (d) justify-content
  25. 25.🎯 Can many elements share the same class? (a) Yes (b) No
  26. 26.💪 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).
  27. 27.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 150px;
      justify-content: flex-end;
    }
    Inside are 2 boxes, each 60px wide (no margins).
  28. 28.🖌️ Which CSS property makes letters bigger? (a) font-size (b) text-align (c) color (d) font-family
  29. 29.🌈 Which hex code is blue? (a) #ffff00 (b) #ffffff (c) #0000ff (d) #000000
  30. 30.🌈 Which hex code is yellow? (a) #ffff00 (b) #ff0000 (c) #ff00ff (d) #0000ff
  31. 31.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 26px;
      }
    }
  32. 32.🖌️ Where does the text sit on its line?
    h2 {
      background-color: black;
      font-size: 12px;
      color: red;
      text-align: center;
    }
    (a) on the right (b) on the left (c) in the middle
  33. 33.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 170px;
      justify-content: flex-start;
    }
    Inside are 4 boxes, each 40px wide (no margins).
  34. 34.🎯 What kind of selector is #top? (a) an id selector (b) a class selector (c) an element selector
  35. 35.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 14px;
      }
    }
  36. 36.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 10px;
      }
    }
  37. 37.True or false: JavaScript changes the page live. (a) True (b) False
  38. 38.🎯 What kind of selector is p? (a) an id selector (b) an element selector (c) a class selector
  39. 39.True or false: HTML checks a quiz answer. (a) True (b) False
  40. 40.🌈 Which colour is #00ff00? (a) red (b) magenta (c) bright green (d) white

Answer key

  1. white
  2. 24
  3. sets colours and fonts
  4. Yes
  5. 800px or wider
  6. an id selector
  7. False
  8. yellow
  9. the viewport meta tag
  10. green
  11. red
  12. text-align
  13. width
  14. #ff0000
  15. 92
  16. purple
  17. bright green
  18. 234
  19. 40
  20. #000000
  21. yellow
  22. 16
  23. magenta
  24. justify-content
  25. Yes
  26. 60
  27. 30
  28. font-size
  29. #0000ff
  30. #ffff00
  31. 20
  32. in the middle
  33. 10
  34. an id selector
  35. 12
  36. 10
  37. True
  38. an element selector
  39. False
  40. bright green

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