← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 469 · 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 does justify-content: center do? (a) puts boxes in the middle (b) packs boxes at the start (c) packs boxes at the end (d) equal gaps, none at ends
  2. 2.🖌️ Which CSS property colours behind the text? (a) font-weight (b) text-align (c) background-color (d) color
  3. 3.⚖️ What colour is the text of this element?
    <p class="box" id="top">Hi</p>
    CSS:
    p { color: orange; }
    p { color: white; }
    (a) blue (b) orange (c) purple (d) white
  4. 4.⚖️ What colour is the text of this element?
    <h1 class="menu" id="hero">Hi</h1>
    CSS:
    #hero { color: yellow; }
    h1 { color: black; }
    (a) green (b) yellow (c) red (d) black
  5. 5.✍️ CSS declarations go inside which brackets? (a) ( ) (b) { } (c) < > (d) [ ]
  6. 6.🧩 Which language changes the text size? (a) CSS (b) JavaScript (c) HTML
  7. 7.What does justify-content: flex-start do? (a) equal gaps, none at ends (b) packs boxes at the end (c) puts boxes in the middle (d) packs boxes at the start
  8. 8.💪 Which flexbox property lines boxes up across? (a) flex-direction (b) display: flex (c) align-items (d) justify-content
  9. 9.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the later one (c) the first one (d) neither
  10. 10.🎯 Which sign starts a class selector? (a) # (b) & (c) . (d) @
  11. 11.⚖️ Which selector is the strongest? (a) an id selector (b) an element selector (c) a class selector
  12. 12.🔍 Which is the odd one out? (a) reacts to a button click (b) changes the text size (c) lays out the page (d) rounds box corners
  13. 13.True or false: padding is a solid or dotted edge. (a) False (b) True
  14. 14.🎯 Which element does the selector h2 style? (a) <div class="red"> (b) <li> (c) <span id="intro"> (d) <h2 class="red">
  15. 15.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 130px;
      padding: 25px;
      border: 5px solid black;
      margin: 15px;
    }
  16. 16.🖌️ Where does the text sit on its line?
    li {
      color: white;
      font-size: 28px;
      text-align: center;
      background-color: yellow;
    }
    (a) on the right (b) on the left (c) in the middle
  17. 17.🖌️ Which CSS property makes the text bold? (a) color (b) background-color (c) text-align (d) font-weight
  18. 18.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 320px;
      justify-content: space-between;
    }
    Inside are 3 boxes, each 100px wide (no margins).
  19. 19.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 280px;
      padding: 15px;
      border: 5px solid black;
      margin: 0px;
    }
  20. 20.✍️ How does a CSS comment start? (a) /* (b) // (c) <!-- (d) #
  21. 21.⚖️ What colour is the text of this element?
    <p class="red" id="logo">Hi</p>
    CSS:
    .red { color: purple; }
    .red { color: black; }
    (a) yellow (b) purple (c) black (d) blue
  22. 22.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 28px;
      }
    }
  23. 23.✍️ What value is given to color in this rule?
    .box {
      text-align: center;
      font-size: 20px;
      font-weight: bold;
      color: red;
    }
    (a) color (b) 20px (c) red (d) center
  24. 24.🖌️ How big is the text, in px?
    li {
      background-color: black;
      text-align: right;
      font-size: 36px;
      color: green;
    }
  25. 25.🌈 Which colour is #ff0000? (a) red (b) magenta (c) blue (d) bright green
  26. 26.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 160px;
      padding: 10px;
      border: 1px solid black;
      margin: 10px;
    }
  27. 27.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 210px;
      padding: 5px;
      border: 1px solid black;
      margin: 20px;
    }
  28. 28.✍️ What is the selector in this CSS rule?
    #top {
      background-color: yellow;
      font-style: italic;
      border: 2px solid;
    }
    (a) background-color (b) #top (c) li (d) italic
  29. 29.📱 The screen is 320px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 22px;
      }
    }
    (a) Yes (b) No
  30. 30.⚖️ What colour is the text of this element?
    <h1 class="big" id="top">Hi</h1>
    CSS:
    #top { color: yellow; }
    #top { color: black; }
    (a) yellow (b) red (c) white (d) black
  31. 31.⚖️ What colour is the text of this element?
    <p class="menu" id="hero">Hi</p>
    CSS:
    p { color: white; }
    p { color: purple; }
    (a) yellow (b) white (c) red (d) purple
  32. 32.True or false: .menu is an element selector. (a) True (b) False
  33. 33.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 10px;
      }
    }
  34. 34.🖌️ How big is the text, in px?
    li {
      text-align: center;
      color: blue;
      font-size: 16px;
      background-color: yellow;
    }
  35. 35.Which of these is padding? (a) space inside the border (b) the line round the box (c) the text or picture (d) space outside the border
  36. 36.🧩 Which language reacts to a button click? (a) JavaScript (b) CSS (c) HTML
  37. 37.🌈 Which hex code is cyan? (a) #0000ff (b) #ff0000 (c) #00ffff (d) #00ff00
  38. 38.✍️ Which sign goes between a property and its value? (a) ; (b) - (c) = (d) :
  39. 39.🌈 Which colour is rgb(0, 0, 0)? (a) black (b) red (c) magenta (d) cyan
  40. 40.🖌️ How big is the text, in px?
    h2 {
      background-color: red;
      text-align: left;
      font-size: 12px;
      color: green;
    }

Answer key

  1. puts boxes in the middle
  2. background-color
  3. white
  4. yellow
  5. { }
  6. CSS
  7. packs boxes at the start
  8. align-items
  9. the later one
  10. .
  11. an id selector
  12. reacts to a button click
  13. False
  14. <h2 class="red">
  15. 220
  16. in the middle
  17. font-weight
  18. 10
  19. 320
  20. /*
  21. black
  22. 20
  23. red
  24. 36
  25. red
  26. 202
  27. 262
  28. #top
  29. No
  30. black
  31. purple
  32. False
  33. 16
  34. 16
  35. space inside the border
  36. JavaScript
  37. #00ffff
  38. :
  39. black
  40. 12

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