← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 13 · 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 flexbox property lines boxes up across? (a) align-items (b) display: flex (c) justify-content (d) flex-direction
  2. 2.🖌️ Which CSS property picks the font style? (a) font-family (b) font-size (c) text-align (d) background-color
  3. 3.✍️ In color: blue; which part is the value? (a) : (b) color (c) ; (d) blue
  4. 4.✍️ What is the selector in this CSS rule?
    .box {
      text-align: center;
      color: red;
    }
    (a) red (b) .box (c) text-align (d) h2
  5. 5.⚖️ What colour is the text of this element?
    <h1 class="star" id="logo">Hi</h1>
    CSS:
    .star { color: purple; }
    .star { color: black; }
    (a) green (b) red (c) black (d) purple
  6. 6.🖌️ Where does the text sit on its line?
    li {
      color: orange;
      text-align: left;
      background-color: white;
      font-size: 36px;
    }
    (a) in the middle (b) on the right (c) on the left
  7. 7.✍️ What is the selector in this CSS rule?
    #top {
      width: 300px;
      text-align: center;
      font-weight: bold;
      color: red;
    }
    (a) width (b) center (c) #top (d) li
  8. 8.🔍 Which is the odd one out? (a) makes a form box (b) makes headings and lists (c) gives the page structure (d) checks a quiz answer
  9. 9.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 22px;
      }
    }
  10. 10.Which of these does HTML do? (a) rounds box corners (b) changes the page live (c) makes a link (d) adds space around boxes
  11. 11.✍️ What is the selector in this CSS rule?
    body {
      background-color: yellow;
      border: 2px solid;
      text-align: center;
    }
    (a) background-color (b) .box (c) body (d) 2px solid
  12. 12.🖌️ How big is the text, in px?
    li {
      color: white;
      text-align: left;
      font-size: 12px;
      background-color: black;
    }
  13. 13.📱 What does a media query check? (a) the page title (b) the screen width (c) the battery level (d) the time of day
  14. 14.True or false: #logo is an id selector. (a) True (b) False
  15. 15.🎯 Which element does the selector #main style? (a) <h1 class="main"> (b) <h2 class="star"> (c) <h1 id="logo"> (d) <h1 id="main">
  16. 16.🌈 Which colour is rgb(0, 0, 255)? (a) black (b) blue (c) red (d) white
  17. 17.🎯 Can many elements share the same class? (a) No (b) Yes
  18. 18.Which of these does JavaScript do? (a) changes the page live (b) gives the page structure (c) makes a link (d) rounds box corners
  19. 19.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 18px;
      }
    }
    (a) No (b) Yes
  20. 20.📦 In the box model, which part is a solid or dotted edge? (a) padding (b) border (c) margin (d) content
  21. 21.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) neither (c) the later one (d) the shorter one
  22. 22.✍️ What value is given to padding in this rule?
    h1 {
      font-size: 20px;
      padding: 8px;
    }
    (a) 8px (b) bold (c) padding (d) 2px solid
  23. 23.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 220px;
      padding: 10px;
      border: 3px solid black;
      margin: 15px;
    }
  24. 24.✍️ What is the selector in this CSS rule?
    h1 {
      font-style: italic;
      background-color: yellow;
      color: red;
      font-size: 20px;
    }
    (a) p (b) h1 (c) font-style (d) yellow
  25. 25.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 140px;
      justify-content: flex-end;
    }
    Inside are 2 boxes, each 40px wide (no margins).
  26. 26.📱 The screen is 540px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 12px;
      }
    }
    (a) Yes (b) No
  27. 27.🧩 Which language adds space around boxes? (a) HTML (b) CSS (c) JavaScript
  28. 28.🧩 Which language gives the page structure? (a) CSS (b) HTML (c) JavaScript
  29. 29.🌈 Which colour is #00ff00? (a) black (b) white (c) bright green (d) magenta
  30. 30.What does justify-content: center do? (a) packs boxes at the start (b) puts boxes in the middle (c) equal gaps, none at ends (d) packs boxes at the end
  31. 31.🖌️ What colour are the letters?
    h2 {
      font-size: 28px;
      color: yellow;
      text-align: center;
      background-color: orange;
    }
    (a) yellow (b) orange (c) black
  32. 32.🖌️ What colour is behind the letters?
    h1 {
      text-align: left;
      font-size: 40px;
      color: orange;
      background-color: purple;
    }
    (a) orange (b) green (c) purple
  33. 33.Which of these does CSS do? (a) adds space around boxes (b) shows a pop-up message (c) puts a picture on a page (d) reacts to a button click
  34. 34.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 200px;
      justify-content: center;
    }
    Inside are 3 boxes, each 60px wide (no margins).
  35. 35.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 2 (b) 4 (c) 6 (d) 3
  36. 36.🎯 Which element does the selector h2 style? (a) <div class="box"> (b) <h2 class="box"> (c) <span id="hero"> (d) <li>
  37. 37.🌈 In #rrggbb, which colour do the last two digits give? (a) blue (b) white (c) green (d) red
  38. 38.🎯 How many elements on a page should have the same id? (a) any number (b) 5 (c) 1 (d) 2
  39. 39.🎯 Which element does the selector p style? (a) <li id="hero"> (b) <h1> (c) <p class="star"> (d) <h2 class="star">
  40. 40.Which of these does JavaScript do? (a) changes the text size (b) shows a pop-up message (c) rounds box corners (d) makes headings and lists

Answer key

  1. align-items
  2. font-family
  3. blue
  4. .box
  5. black
  6. on the left
  7. #top
  8. checks a quiz answer
  9. 24
  10. makes a link
  11. body
  12. 12
  13. the screen width
  14. True
  15. <h1 id="main">
  16. blue
  17. Yes
  18. changes the page live
  19. Yes
  20. border
  21. the later one
  22. 8px
  23. 276
  24. h1
  25. 60
  26. Yes
  27. CSS
  28. HTML
  29. bright green
  30. puts boxes in the middle
  31. yellow
  32. purple
  33. adds space around boxes
  34. 10
  35. 3
  36. <h2 class="box">
  37. blue
  38. 1
  39. <p class="star">
  40. shows a pop-up message

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