← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 817 · 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 background-color in this rule?
    li {
      font-weight: bold;
      background-color: yellow;
    }
    (a) background-color (b) 8px (c) yellow (d) 10px
  2. 2.True or false: #top is an id selector. (a) False (b) True
  3. 3.🖌️ How big is the text, in px?
    h1 {
      font-size: 20px;
      color: white;
      background-color: purple;
      text-align: center;
    }
  4. 4.Which of these does HTML do? (a) reacts to a button click (b) gives the page structure (c) lays out the page (d) changes the text size
  5. 5.📱 Which tag helps phones show a page at the right size? (a) the hr tag (b) the viewport meta tag (c) the title tag (d) the br tag
  6. 6.🎯 Which CSS selector matches this element?
    <h2 class="big" id="end">Hello</h2>
    (a) #big (b) .red (c) h2 (d) .end
  7. 7.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 130px;
      justify-content: flex-end;
    }
    Inside are 2 boxes, each 40px wide (no margins).
  8. 8.💪 Which justify-content value packs boxes at the end? (a) center (b) flex-start (c) flex-end (d) space-between
  9. 9.Which of these does HTML do? (a) makes headings and lists (b) checks a quiz answer (c) adds space around boxes (d) shows a pop-up message
  10. 10.✍️ How many declarations (property: value pairs) are in this rule?
    .box {
      font-size: 20px;
      border: 2px solid;
      margin: 10px;
      text-align: center;
    }
  11. 11.📱 The screen is 1366px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 10px;
      }
    }
    (a) No (b) Yes
  12. 12.True or false: .menu is a class selector. (a) True (b) False
  13. 13.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 16px;
      }
    }
  14. 14.✍️ In color: blue; which part is the property? (a) ; (b) blue (c) : (d) color
  15. 15.What does background-color do? (a) picks the font style (b) makes letters bigger (c) colours behind the text (d) makes the text bold
  16. 16.🎯 Which element does the selector #main style? (a) <p id="logo"> (b) <p id="main"> (c) <h1 class="box"> (d) <p class="main">
  17. 17.📱 The screen is 1366px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 14px;
      }
    }
    (a) No (b) Yes
  18. 18.💪 Which flexbox property sets space between boxes? (a) flex-direction (b) justify-content (c) display: flex (d) gap
  19. 19.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      margin: 10px;
      text-align: center;
    }
  20. 20.True or false: CSS makes a link. (a) False (b) True
  21. 21.✍️ Which property is set to italic in this rule?
    .box {
      background-color: yellow;
      width: 300px;
      font-style: italic;
    }
    (a) font-style (b) font-size (c) color (d) italic
  22. 22.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) red (c) blue (d) white
  23. 23.✍️ What is the selector in this CSS rule?
    .box {
      font-size: 20px;
      border: 2px solid;
      padding: 8px;
    }
    (a) font-size (b) 2px solid (c) h2 (d) .box
  24. 24.🖌️ What colour are the letters?
    h1 {
      text-align: left;
      color: black;
      font-size: 12px;
      background-color: orange;
    }
    (a) orange (b) black (c) green
  25. 25.🖌️ Which CSS property picks the font style? (a) font-family (b) text-align (c) font-size (d) background-color
  26. 26.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the first one (c) neither (d) the later one
  27. 27.✍️ Which property is set to 2px solid in this rule?
    body {
      border: 2px solid;
      margin: 10px;
    }
    (a) font-style (b) width (c) border (d) 2px solid
  28. 28.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 18px;
      }
    }
  29. 29.✍️ Which property is set to red in this rule?
    .note {
      padding: 8px;
      color: red;
      width: 300px;
    }
    (a) red (b) font-size (c) text-align (d) color
  30. 30.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 100px;
      padding: 25px;
      border: 4px solid black;
      margin: 0px;
    }
  31. 31.True or false: #top is a class selector. (a) True (b) False
  32. 32.🎯 What kind of selector is img? (a) an id selector (b) a class selector (c) an element selector
  33. 33.Which of these does JavaScript do? (a) rounds box corners (b) makes headings and lists (c) reacts to a button click (d) lays out the page
  34. 34.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 200px;
      padding: 10px;
      border: 2px solid black;
      margin: 10px;
    }
  35. 35.True or false: CSS changes the page live. (a) False (b) True
  36. 36.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
  37. 37.⚖️ What colour is the text of this element?
    <p class="star" id="main">Hi</p>
    CSS:
    p { color: green; }
    p { color: white; }
    (a) orange (b) purple (c) green (d) white
  38. 38.💪 Which justify-content value packs boxes at the start? (a) space-between (b) flex-start (c) flex-end (d) center
  39. 39.💪 Which justify-content value puts boxes in the middle? (a) flex-end (b) space-between (c) center (d) flex-start
  40. 40.📱 The screen is 1366px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 18px;
      }
    }
    (a) Yes (b) No

Answer key

  1. yellow
  2. True
  3. 20
  4. gives the page structure
  5. the viewport meta tag
  6. h2
  7. 50
  8. flex-end
  9. makes headings and lists
  10. 4
  11. No
  12. True
  13. 20
  14. color
  15. colours behind the text
  16. <p id="main">
  17. No
  18. gap
  19. 2
  20. False
  21. font-style
  22. blue
  23. .box
  24. black
  25. font-family
  26. the later one
  27. border
  28. 24
  29. color
  30. 158
  31. False
  32. an element selector
  33. reacts to a button click
  34. 224
  35. False
  36. an element selector
  37. white
  38. flex-start
  39. center
  40. No

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