← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 259 · 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.🎯 Which element does the selector p style? (a) <h2 class="red"> (b) <p class="red"> (c) <li id="top"> (d) <h1>
  2. 2.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 6px;
      }
    }
  3. 3.Which of these is the border? (a) space outside the border (b) space inside the border (c) the gap to other boxes (d) the line round the box
  4. 4.📱 The screen is 820px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 20px;
      }
    }
    (a) No (b) Yes
  5. 5.🎯 Can many elements share the same class? (a) No (b) Yes
  6. 6.🎯 Which sign starts an id selector? (a) @ (b) . (c) # (d) &
  7. 7.🎯 Which element does the selector li style? (a) <span class="star"> (b) <div> (c) <li class="star"> (d) <p id="main">
  8. 8.What does justify-content: flex-end do? (a) packs boxes at the start (b) equal gaps, none at ends (c) packs boxes at the end (d) puts boxes in the middle
  9. 9.✍️ CSS declarations go inside which brackets? (a) ( ) (b) [ ] (c) { } (d) < >
  10. 10.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 110px;
      padding: 15px;
      border: 4px solid black;
      margin: 0px;
    }
  11. 11.🎯 Which element does the selector div style? (a) <div class="red"> (b) <h1 id="intro"> (c) <p class="red"> (d) <span>
  12. 12.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 210px;
      justify-content: flex-start;
    }
    Inside are 4 boxes, each 40px wide (no margins).
  13. 13.What does font-size do? (a) makes the text bold (b) sets the letter colour (c) makes letters bigger (d) centres a heading
  14. 14.✍️ In color: blue; which part is the value? (a) : (b) ; (c) color (d) blue
  15. 15.🌈 Which colour of light is strongest in rgb(1, 154, 10)? (a) blue (b) red (c) green
  16. 16.✍️ Which sign ends each CSS declaration? (a) . (b) ; (c) , (d) :
  17. 17.💪 Which justify-content value packs boxes at the start? (a) center (b) flex-end (c) flex-start (d) space-between
  18. 18.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 80px;
      padding: 5px;
      border: 2px solid black;
      margin: 0px;
    }
  19. 19.📱 What does a media query check? (a) the battery level (b) the screen width (c) the time of day (d) the page title
  20. 20.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 110px;
      padding: 5px;
      border: 5px solid black;
      margin: 5px;
    }
  21. 21.✍️ What is the selector in this CSS rule?
    p {
      font-weight: bold;
      font-style: italic;
      padding: 8px;
    }
    (a) p (b) italic (c) .note (d) font-weight
  22. 22.🧩 Which language shows a pop-up message? (a) HTML (b) JavaScript (c) CSS
  23. 23.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 10px;
      }
    }
  24. 24.⚖️ What colour is the text of this element?
    <p class="star" id="intro">Hi</p>
    CSS:
    .star { color: purple; }
    p { color: blue; }
    #intro { color: red; }
    (a) purple (b) blue (c) red (d) yellow
  25. 25.🧩 Which language counts down a timer? (a) JavaScript (b) CSS (c) HTML
  26. 26.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 6 (b) 2 (c) 4 (d) 3
  27. 27.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 140px;
      justify-content: center;
    }
    Inside are 3 boxes, each 40px wide (no margins).
  28. 28.True or false: #hero is an id selector. (a) True (b) False
  29. 29.What does color do? (a) colours behind the text (b) sets the letter colour (c) centres a heading (d) makes letters bigger
  30. 30.⚖️ What colour is the text of this element?
    <p class="note" id="top">Hi</p>
    CSS:
    .note { color: purple; }
    #top { color: orange; }
    (a) orange (b) purple (c) blue (d) red
  31. 31.True or false: body is an element selector. (a) False (b) True
  32. 32.True or false: padding is the gap round content. (a) True (b) False
  33. 33.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      background-color: yellow;
      font-size: 20px;
      font-style: italic;
    }
  34. 34.📦 In the box model, which part is the line round the box? (a) margin (b) padding (c) border (d) content
  35. 35.🖌️ What colour are the letters?
    li {
      color: blue;
      background-color: white;
      text-align: left;
      font-size: 12px;
    }
    (a) green (b) blue (c) white
  36. 36.💪 Which flexbox property sets space between boxes? (a) display: flex (b) flex-direction (c) gap (d) justify-content
  37. 37.🎯 Which element does the selector .big style? (a) <h2 class="big"> (b) <h2 class="red"> (c) <li class="box"> (d) <h2 id="big">
  38. 38.True or false: .star is an id selector. (a) True (b) False
  39. 39.💪 Which flexbox property picks row or column? (a) gap (b) flex-direction (c) display: flex (d) justify-content
  40. 40.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 26px;
      }
    }

Answer key

  1. <p class="red">
  2. 6
  3. the line round the box
  4. No
  5. Yes
  6. #
  7. <li class="star">
  8. packs boxes at the end
  9. { }
  10. 148
  11. <div class="red">
  12. 50
  13. makes letters bigger
  14. blue
  15. green
  16. ;
  17. flex-start
  18. 94
  19. the screen width
  20. 140
  21. p
  22. JavaScript
  23. 16
  24. red
  25. JavaScript
  26. 3
  27. 10
  28. True
  29. sets the letter colour
  30. orange
  31. True
  32. True
  33. 3
  34. border
  35. blue
  36. gap
  37. <h2 class="big">
  38. False
  39. flex-direction
  40. 24

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