← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 170 · 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.📱 max-width: 600px applies when the screen is ___. (a) turned off (b) 600px or narrower (c) 600px or wider (d) exactly 1000px
  2. 2.🔍 Which is the odd one out? (a) sets colours and fonts (b) adds space around boxes (c) rounds box corners (d) reacts to a button click
  3. 3.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 150px;
      justify-content: flex-end;
    }
    Inside are 2 boxes, each 60px wide (no margins).
  4. 4.⚖️ What colour is the text of this element?
    <h1 class="big" id="top">Hi</h1>
    CSS:
    #top { color: white; }
    #top { color: black; }
    (a) black (b) blue (c) white (d) red
  5. 5.✍️ CSS declarations go inside which brackets? (a) < > (b) [ ] (c) ( ) (d) { }
  6. 6.🌈 Which colour is rgb(255, 255, 0)? (a) red (b) blue (c) yellow (d) bright green
  7. 7.True or false: JavaScript sets colours and fonts. (a) True (b) False
  8. 8.💪 Which justify-content value equal gaps, none at ends? (a) space-between (b) center (c) flex-start (d) flex-end
  9. 9.🖌️ Which CSS property colours behind the text? (a) color (b) font-family (c) font-size (d) background-color
  10. 10.Which of these does HTML do? (a) makes headings and lists (b) rounds box corners (c) changes the page live (d) shows a pop-up message
  11. 11.✍️ Which property is set to 8px in this rule?
    p {
      border: 2px solid;
      padding: 8px;
    }
    (a) 8px (b) font-weight (c) border (d) padding
  12. 12.🖌️ What colour are the letters?
    h1 {
      background-color: purple;
      color: black;
      text-align: left;
      font-size: 16px;
    }
    (a) black (b) purple (c) orange
  13. 13.🎯 Which element does the selector .star style? (a) <span class="menu"> (b) <span class="star"> (c) <p class="note"> (d) <span id="star">
  14. 14.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 6 (b) 3 (c) 4 (d) 2
  15. 15.🎯 How many elements on a page should have the same id? (a) 5 (b) 1 (c) any number (d) 2
  16. 16.📦 In the box model, which part is the gap to other boxes? (a) content (b) padding (c) border (d) margin
  17. 17.⚖️ Which selector is the strongest? (a) an id selector (b) an element selector (c) a class selector
  18. 18.🌈 Which hex code is bright green? (a) #0000ff (b) #000000 (c) #00ffff (d) #00ff00
  19. 19.⚖️ What colour is the text of this element?
    <h2 class="red" id="end">Hi</h2>
    CSS:
    #end { color: yellow; }
    h2 { color: black; }
    (a) green (b) red (c) yellow (d) black
  20. 20.📱 The screen is 820px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 22px;
      }
    }
    (a) No (b) Yes
  21. 21.True or false: CSS changes the text size. (a) True (b) False
  22. 22.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 220px;
      padding: 25px;
      border: 4px solid black;
      margin: 15px;
    }
  23. 23.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
  24. 24.✍️ Which sign goes between a property and its value? (a) - (b) ; (c) = (d) :
  25. 25.🎯 Which CSS selector matches this element?
    <p class="red" id="intro">Hello</p>
    (a) #red (b) #main (c) .box (d) .red
  26. 26.🌈 Which colour is rgb(0, 0, 0)? (a) black (b) white (c) magenta (d) bright green
  27. 27.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      text-align: center;
      color: red;
      font-size: 20px;
      width: 300px;
    }
  28. 28.🧩 Which language changes the page live? (a) JavaScript (b) CSS (c) HTML
  29. 29.🧩 Which language shows a pop-up message? (a) HTML (b) CSS (c) JavaScript
  30. 30.🖌️ How big is the text, in px?
    li {
      background-color: green;
      font-size: 12px;
      color: red;
      text-align: center;
    }
  31. 31.✍️ Which property is set to 20px in this rule?
    .note {
      font-size: 20px;
      margin: 10px;
      background-color: yellow;
      padding: 8px;
    }
    (a) 20px (b) font-size (c) text-align (d) background-color
  32. 32.✍️ What value is given to padding in this rule?
    h1 {
      width: 300px;
      margin: 10px;
      padding: 8px;
      font-size: 20px;
    }
    (a) 8px (b) padding (c) 2px solid (d) bold
  33. 33.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the shorter one (c) the first one (d) the later one
  34. 34.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 260px;
      justify-content: flex-start;
    }
    Inside are 3 boxes, each 80px wide (no margins).
  35. 35.✍️ Which property is set to yellow in this rule?
    h2 {
      width: 300px;
      color: red;
      background-color: yellow;
      font-style: italic;
    }
    (a) yellow (b) margin (c) background-color (d) padding
  36. 36.🌈 Which colour is #ffffff? (a) white (b) black (c) red (d) magenta
  37. 37.🎯 Which CSS selector matches this element?
    <li class="red" id="intro">Hello</li>
    (a) .box (b) .intro (c) #intro (d) div
  38. 38.✍️ What value is given to text-align in this rule?
    h2 {
      border: 2px solid;
      font-style: italic;
      text-align: center;
    }
    (a) text-align (b) yellow (c) center (d) 10px
  39. 39.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 160px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 50px wide (no margins).
  40. 40.Which of these does CSS do? (a) rounds box corners (b) counts down a timer (c) gives the page structure (d) checks a quiz answer

Answer key

  1. 600px or narrower
  2. reacts to a button click
  3. 30
  4. black
  5. { }
  6. yellow
  7. False
  8. space-between
  9. background-color
  10. makes headings and lists
  11. padding
  12. black
  13. <span class="star">
  14. 3
  15. 1
  16. margin
  17. an id selector
  18. #00ff00
  19. yellow
  20. Yes
  21. True
  22. 278
  23. an element selector
  24. :
  25. .red
  26. black
  27. 4
  28. JavaScript
  29. JavaScript
  30. 12
  31. font-size
  32. 8px
  33. the later one
  34. 20
  35. background-color
  36. white
  37. #intro
  38. center
  39. 60
  40. rounds box corners

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