← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 940 · 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 are the letters?
    h2 {
      color: blue;
      background-color: red;
      text-align: left;
      font-size: 16px;
    }
    (a) red (b) blue (c) purple
  2. 2.🧩 Which language sets colours and fonts? (a) JavaScript (b) CSS (c) HTML
  3. 3.⚖️ What colour is the text of this element?
    <p class="red" id="top">Hi</p>
    CSS:
    .red { color: purple; }
    p { color: black; }
    #top { color: yellow; }
    (a) purple (b) black (c) yellow (d) red
  4. 4.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      font-size: 20px;
      border: 2px solid;
      text-align: center;
      color: red;
    }
  5. 5.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 20px;
      }
    }
    (a) Yes (b) No
  6. 6.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 140px;
      padding: 30px;
      border: 5px solid black;
      margin: 0px;
    }
  7. 7.🌈 Which colour of light is strongest in rgb(28, 59, 230)? (a) red (b) blue (c) green
  8. 8.⚖️ What colour is the text of this element?
    <h1 class="big" id="intro">Hi</h1>
    CSS:
    .big { color: green; }
    .big { color: yellow; }
    (a) orange (b) green (c) yellow (d) black
  9. 9.🖌️ What colour are the letters?
    li {
      color: green;
      text-align: left;
      background-color: blue;
      font-size: 28px;
    }
    (a) blue (b) orange (c) green
  10. 10.🔍 Which is the odd one out? (a) makes headings and lists (b) lays out the page (c) rounds box corners (d) adds space around boxes
  11. 11.🖌️ Where does the text sit on its line?
    p {
      color: black;
      font-size: 20px;
      text-align: right;
      background-color: blue;
    }
    (a) on the right (b) in the middle (c) on the left
  12. 12.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
  13. 13.True or false: .big is a class selector. (a) False (b) True
  14. 14.💪 Which justify-content value packs boxes at the end? (a) flex-start (b) center (c) space-between (d) flex-end
  15. 15.What does font-family do? (a) picks the font style (b) centres a heading (c) makes letters bigger (d) makes the text bold
  16. 16.🖌️ What colour is behind the letters?
    h1 {
      text-align: center;
      background-color: green;
      font-size: 36px;
      color: blue;
    }
    (a) white (b) green (c) blue
  17. 17.🖌️ Where does the text sit on its line?
    h2 {
      color: purple;
      text-align: center;
      font-size: 40px;
      background-color: red;
    }
    (a) on the left (b) on the right (c) in the middle
  18. 18.📱 Responsive design means a page ___. (a) never changes (b) is only for laptops (c) has no pictures (d) fits every screen
  19. 19.True or false: the border is the line round the box. (a) True (b) False
  20. 20.🖌️ Which CSS property colours behind the text? (a) font-family (b) color (c) background-color (d) text-align
  21. 21.✍️ What is the selector in this CSS rule?
    .box {
      color: red;
      padding: 8px;
      margin: 10px;
      background-color: yellow;
    }
    (a) 8px (b) color (c) .box (d) h2
  22. 22.⚖️ Which selector is the weakest? (a) an element selector (b) a class selector (c) an id selector
  23. 23.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 360px;
      justify-content: center;
    }
    Inside are 3 boxes, each 100px wide (no margins).
  24. 24.🌈 Which colour is #ff00ff? (a) white (b) magenta (c) yellow (d) bright green
  25. 25.🎯 What kind of selector is p? (a) an id selector (b) an element selector (c) a class selector
  26. 26.True or false: #top is an id selector. (a) False (b) True
  27. 27.🖌️ What colour are the letters?
    h1 {
      background-color: blue;
      text-align: left;
      font-size: 40px;
      color: yellow;
    }
    (a) orange (b) yellow (c) blue
  28. 28.True or false: the content is a solid or dotted edge. (a) True (b) False
  29. 29.✍️ CSS declarations go inside which brackets? (a) < > (b) [ ] (c) { } (d) ( )
  30. 30.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 260px;
      justify-content: center;
    }
    Inside are 4 boxes, each 60px wide (no margins).
  31. 31.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 140px;
      padding: 25px;
      border: 2px solid black;
      margin: 20px;
    }
  32. 32.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 22px;
      }
    }
  33. 33.Which of these does CSS do? (a) changes the page live (b) counts down a timer (c) sets colours and fonts (d) gives the page structure
  34. 34.✍️ Which sign ends each CSS declaration? (a) , (b) ; (c) : (d) .
  35. 35.🌈 In #rrggbb, which colour do the first two digits give? (a) black (b) red (c) green (d) blue
  36. 36.What does justify-content: center do? (a) packs boxes at the end (b) packs boxes at the start (c) puts boxes in the middle (d) equal gaps, none at ends
  37. 37.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 250px;
      padding: 25px;
      border: 5px solid black;
      margin: 20px;
    }
  38. 38.🖌️ Which CSS property makes the text bold? (a) font-weight (b) font-size (c) color (d) text-align
  39. 39.True or false: padding is the gap round content. (a) True (b) False
  40. 40.📱 The screen is 320px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 10px;
      }
    }
    (a) Yes (b) No

Answer key

  1. blue
  2. CSS
  3. yellow
  4. 4
  5. Yes
  6. 210
  7. blue
  8. yellow
  9. green
  10. makes headings and lists
  11. on the right
  12. an id selector
  13. True
  14. flex-end
  15. picks the font style
  16. green
  17. in the middle
  18. fits every screen
  19. True
  20. background-color
  21. .box
  22. an element selector
  23. 30
  24. magenta
  25. an element selector
  26. True
  27. yellow
  28. False
  29. { }
  30. 10
  31. 234
  32. 22
  33. sets colours and fonts
  34. ;
  35. red
  36. puts boxes in the middle
  37. 350
  38. font-weight
  39. True
  40. Yes

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