← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 540 · 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 justify-content value puts boxes in the middle? (a) flex-end (b) center (c) space-between (d) flex-start
  2. 2.✍️ Which property is set to 20px in this rule?
    h2 {
      font-style: italic;
      font-size: 20px;
      border: 2px solid;
    }
    (a) background-color (b) text-align (c) font-size (d) 20px
  3. 3.📱 min-width: 800px applies when the screen is ___. (a) exactly 100px (b) 800px or wider (c) 800px or narrower (d) turned off
  4. 4.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 6 (b) 2 (c) 4 (d) 3
  5. 5.✍️ Which property is set to italic in this rule?
    li {
      width: 300px;
      font-style: italic;
    }
    (a) font-size (b) italic (c) font-style (d) color
  6. 6.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 120px;
      padding: 25px;
      border: 1px solid black;
      margin: 0px;
    }
  7. 7.What does text-align do? (a) centres a heading (b) picks the font style (c) makes letters bigger (d) colours behind the text
  8. 8.🖌️ What colour is behind the letters?
    h1 {
      background-color: red;
      text-align: left;
      color: blue;
      font-size: 40px;
    }
    (a) black (b) red (c) blue
  9. 9.✍️ Which property is set to 10px in this rule?
    h2 {
      font-weight: bold;
      margin: 10px;
      font-style: italic;
      width: 300px;
    }
    (a) 10px (b) padding (c) margin (d) font-weight
  10. 10.Which of these is padding? (a) the line round the box (b) the gap to other boxes (c) a solid or dotted edge (d) space inside the border
  11. 11.🔍 Which is the odd one out? (a) makes a link (b) gives the page structure (c) sets colours and fonts (d) puts a picture on a page
  12. 12.🎯 Which CSS selector matches this element?
    <p class="menu" id="end">Hello</p>
    (a) .note (b) #menu (c) .end (d) p
  13. 13.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 6px;
      }
    }
  14. 14.What does font-size do? (a) centres a heading (b) colours behind the text (c) picks the font style (d) makes letters bigger
  15. 15.⚖️ What colour is the text of this element?
    <p class="star" id="top">Hi</p>
    CSS:
    #top { color: red; }
    .star { color: black; }
    (a) blue (b) black (c) orange (d) red
  16. 16.🌈 Which colour is rgb(255, 255, 0)? (a) red (b) cyan (c) yellow (d) white
  17. 17.⚖️ What colour is the text of this element?
    <h2 class="big" id="hero">Hi</h2>
    CSS:
    h2 { color: red; }
    #hero { color: white; }
    (a) red (b) green (c) black (d) white
  18. 18.True or false: JavaScript shows a pop-up message. (a) False (b) True
  19. 19.🌈 Which colour of light is strongest in rgb(28, 124, 203)? (a) red (b) blue (c) green
  20. 20.🎯 Which element does the selector li style? (a) <div> (b) <p id="top"> (c) <li class="note"> (d) <span class="note">
  21. 21.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) neither (c) the shorter one (d) the later one
  22. 22.🎯 Which element does the selector .note style? (a) <p class="note"> (b) <h1 class="red"> (c) <p class="big"> (d) <p id="note">
  23. 23.✍️ Which sign ends each CSS declaration? (a) . (b) : (c) ; (d) ,
  24. 24.🔍 Which is the odd one out? (a) reacts to a button click (b) changes the text size (c) shows a pop-up message (d) counts down a timer
  25. 25.🌈 In #009c00 the green part is the hex number 9c. What is it as a normal number?
  26. 26.True or false: img is an element selector. (a) True (b) False
  27. 27.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 140px;
      justify-content: space-between;
    }
    Inside are 2 boxes, each 50px wide (no margins).
  28. 28.🎯 Which element does the selector #top style? (a) <span class="box"> (b) <div class="top"> (c) <div id="intro"> (d) <div id="top">
  29. 29.🎯 Can many elements share the same class? (a) No (b) Yes
  30. 30.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 50px;
      padding: 20px;
      border: 4px solid black;
      margin: 15px;
    }
  31. 31.✍️ How many declarations (property: value pairs) are in this rule?
    .box {
      border: 2px solid;
      padding: 8px;
      color: red;
      margin: 10px;
    }
  32. 32.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 190px;
      justify-content: flex-end;
    }
    Inside are 4 boxes, each 40px wide (no margins).
  33. 33.📱 The screen is 1366px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 18px;
      }
    }
    (a) No (b) Yes
  34. 34.✍️ In color: blue; which part is the property? (a) ; (b) : (c) blue (d) color
  35. 35.🎯 Which sign starts a class selector? (a) & (b) # (c) @ (d) .
  36. 36.🎯 Which CSS selector matches this element?
    <span class="menu" id="hero">Hello</span>
    (a) p (b) span (c) #menu (d) #top
  37. 37.🎨 Which attribute adds CSS inside one tag? (a) alt (b) src (c) style (d) href
  38. 38.🎯 What kind of selector is #end? (a) a class selector (b) an element selector (c) an id selector
  39. 39.🌈 In #610000 the red part is the hex number 61. What is it as a normal number?
  40. 40.🎯 What kind of selector is #logo? (a) an element selector (b) an id selector (c) a class selector

Answer key

  1. center
  2. font-size
  3. 800px or wider
  4. 3
  5. font-style
  6. 172
  7. centres a heading
  8. red
  9. margin
  10. space inside the border
  11. sets colours and fonts
  12. p
  13. 6
  14. makes letters bigger
  15. red
  16. yellow
  17. white
  18. True
  19. blue
  20. <li class="note">
  21. the later one
  22. <p class="note">
  23. ;
  24. changes the text size
  25. 156
  26. True
  27. 40
  28. <div id="top">
  29. Yes
  30. 128
  31. 4
  32. 30
  33. No
  34. color
  35. .
  36. span
  37. style
  38. an id selector
  39. 97
  40. an id selector

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