← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 939 · 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?
    <h2 class="box" id="main">Hi</h2>
    CSS:
    h2 { color: blue; }
    .box { color: green; }
    (a) white (b) yellow (c) green (d) blue
  2. 2.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 320px;
      justify-content: center;
    }
    Inside are 2 boxes, each 100px wide (no margins).
  3. 3.📦 In the box model, which part is the gap to other boxes? (a) border (b) padding (c) margin (d) content
  4. 4.📱 The screen is 375px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 18px;
      }
    }
    (a) No (b) Yes
  5. 5.True or false: the border is the line round the box. (a) False (b) True
  6. 6.True or false: .note is a class selector. (a) False (b) True
  7. 7.🖌️ Which CSS property centres a heading? (a) font-family (b) background-color (c) text-align (d) color
  8. 8.💪 Which flexbox property picks row or column? (a) gap (b) flex-direction (c) display: flex (d) justify-content
  9. 9.⚖️ Which selector is the strongest? (a) an id selector (b) a class selector (c) an element selector
  10. 10.✍️ What is the selector in this CSS rule?
    .box {
      margin: 10px;
      background-color: yellow;
    }
    (a) .box (b) h2 (c) yellow (d) margin
  11. 11.🖌️ Where does the text sit on its line?
    h1 {
      background-color: red;
      text-align: center;
      font-size: 36px;
      color: white;
    }
    (a) on the right (b) on the left (c) in the middle
  12. 12.🧩 Which language shows a pop-up message? (a) HTML (b) CSS (c) JavaScript
  13. 13.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 8px;
      }
    }
  14. 14.🎯 Which CSS selector matches this element?
    <p class="note" id="intro">Hello</p>
    (a) #intro (b) h1 (c) #main (d) .intro
  15. 15.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      color: red;
      font-size: 20px;
    }
  16. 16.🖌️ Where does the text sit on its line?
    p {
      text-align: right;
      background-color: white;
      font-size: 40px;
      color: black;
    }
    (a) in the middle (b) on the right (c) on the left
  17. 17.🖌️ Which CSS property makes letters bigger? (a) font-family (b) color (c) font-weight (d) font-size
  18. 18.🎯 What kind of selector is .big? (a) an element selector (b) an id selector (c) a class selector
  19. 19.Which of these does HTML do? (a) rounds box corners (b) puts a picture on a page (c) counts down a timer (d) changes the page live
  20. 20.✍️ In color: blue; which part is the property? (a) blue (b) ; (c) : (d) color
  21. 21.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 70px;
      padding: 10px;
      border: 1px solid black;
      margin: 15px;
    }
  22. 22.⚖️ What colour is the text of this element?
    <p class="big" id="end">Hi</p>
    CSS:
    .big { color: blue; }
    .big { color: red; }
    (a) blue (b) white (c) green (d) red
  23. 23.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 18px;
      }
    }
  24. 24.⚖️ What colour is the text of this element?
    <p class="big" id="top">Hi</p>
    CSS:
    p { color: blue; }
    #top { color: orange; }
    .big { color: green; }
    (a) black (b) orange (c) blue (d) green
  25. 25.📱 What does a media query check? (a) the time of day (b) the battery level (c) the screen width (d) the page title
  26. 26.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 190px;
      padding: 20px;
      border: 1px solid black;
      margin: 20px;
    }
  27. 27.🌈 In #rrggbb, which colour do the last two digits give? (a) white (b) blue (c) green (d) red
  28. 28.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 230px;
      padding: 25px;
      border: 4px solid black;
      margin: 15px;
    }
  29. 29.🌈 In #5f0000 the red part is the hex number 5f. What is it as a normal number?
  30. 30.✍️ What is the selector in this CSS rule?
    .box {
      border: 2px solid;
      text-align: center;
      color: red;
      background-color: yellow;
    }
    (a) h2 (b) .box (c) border (d) center
  31. 31.✍️ What value is given to text-align in this rule?
    body {
      padding: 8px;
      color: red;
      font-weight: bold;
      text-align: center;
    }
    (a) 10px (b) yellow (c) text-align (d) center
  32. 32.🎯 What kind of selector is #logo? (a) an element selector (b) a class selector (c) an id selector
  33. 33.🔍 Which is the odd one out? (a) makes a link (b) reacts to a button click (c) counts down a timer (d) changes the page live
  34. 34.What does justify-content: space-between do? (a) equal gaps, none at ends (b) puts boxes in the middle (c) packs boxes at the start (d) packs boxes at the end
  35. 35.🌈 Which colour is #ff00ff? (a) cyan (b) blue (c) magenta (d) white
  36. 36.🎯 Which CSS selector matches this element?
    <h1 class="note" id="main">Hello</h1>
    (a) h2 (b) #note (c) .note (d) .big
  37. 37.✍️ Which sign ends each CSS declaration? (a) : (b) ; (c) . (d) ,
  38. 38.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 8px;
      }
    }
  39. 39.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 190px;
      justify-content: flex-end;
    }
    Inside are 2 boxes, each 60px wide (no margins).
  40. 40.🎨 Which tag connects an outside CSS file? (a) <css> (b) <link> (c) <a> (d) <img>

Answer key

  1. green
  2. 60
  3. margin
  4. No
  5. True
  6. True
  7. text-align
  8. flex-direction
  9. an id selector
  10. .box
  11. in the middle
  12. JavaScript
  13. 8
  14. #intro
  15. 2
  16. on the right
  17. font-size
  18. a class selector
  19. puts a picture on a page
  20. color
  21. 122
  22. red
  23. 16
  24. orange
  25. the screen width
  26. 272
  27. blue
  28. 318
  29. 95
  30. .box
  31. center
  32. an id selector
  33. makes a link
  34. equal gaps, none at ends
  35. magenta
  36. .note
  37. ;
  38. 12
  39. 70
  40. <link>

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