← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 571 · 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.📦 In the box model, which part is the line round the box? (a) content (b) margin (c) padding (d) border
  2. 2.True or false: CSS checks a quiz answer. (a) True (b) False
  3. 3.🎯 How many elements on a page should have the same id? (a) any number (b) 5 (c) 1 (d) 2
  4. 4.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 90px;
      padding: 10px;
      border: 3px solid black;
      margin: 20px;
    }
  5. 5.🧩 Which language sets colours and fonts? (a) HTML (b) JavaScript (c) CSS
  6. 6.🌈 Which colour is rgb(255, 0, 255)? (a) red (b) magenta (c) white (d) yellow
  7. 7.🌈 Which colour is rgb(0, 255, 255)? (a) blue (b) cyan (c) bright green (d) yellow
  8. 8.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
  9. 9.🌈 Which colour of light is strongest in rgb(174, 65, 88)? (a) red (b) green (c) blue
  10. 10.🎯 Which sign starts a class selector? (a) @ (b) # (c) . (d) &
  11. 11.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
  12. 12.✍️ Which property is set to italic in this rule?
    .box {
      background-color: yellow;
      font-style: italic;
    }
    (a) font-style (b) font-size (c) color (d) italic
  13. 13.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      margin: 10px;
      font-style: italic;
      color: red;
      background-color: yellow;
    }
  14. 14.📱 Responsive design means a page ___. (a) fits every screen (b) has no pictures (c) never changes (d) is only for laptops
  15. 15.True or false: CSS makes a form box. (a) False (b) True
  16. 16.🖌️ What colour are the letters?
    h1 {
      background-color: red;
      color: black;
      font-size: 36px;
      text-align: center;
    }
    (a) black (b) purple (c) red
  17. 17.✍️ What is the selector in this CSS rule?
    .box {
      margin: 10px;
      border: 2px solid;
      background-color: yellow;
    }
    (a) h2 (b) .box (c) margin (d) 2px solid
  18. 18.⚖️ What colour is the text of this element?
    <p class="menu" id="intro">Hi</p>
    CSS:
    p { color: red; }
    #intro { color: blue; }
    .menu { color: yellow; }
    (a) yellow (b) red (c) black (d) blue
  19. 19.🎨 Which tag holds CSS inside the head? (a) <style> (b) <body> (c) <css> (d) <script>
  20. 20.💪 Which justify-content value packs boxes at the start? (a) center (b) flex-start (c) space-between (d) flex-end
  21. 21.📱 The screen is 375px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 18px;
      }
    }
    (a) No (b) Yes
  22. 22.💪 Which flexbox property spaces boxes along a row? (a) align-items (b) display: flex (c) justify-content (d) flex-direction
  23. 23.🎯 Which CSS selector matches this element?
    <div class="box" id="end">Hello</div>
    (a) .box (b) span (c) #hero (d) #box
  24. 24.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) neither (c) the first one (d) the later one
  25. 25.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 540px;
      justify-content: center;
    }
    Inside are 4 boxes, each 100px wide (no margins).
  26. 26.🖌️ Where does the text sit on its line?
    h1 {
      color: blue;
      background-color: yellow;
      text-align: center;
      font-size: 12px;
    }
    (a) on the right (b) on the left (c) in the middle
  27. 27.True or false: CSS shows a pop-up message. (a) True (b) False
  28. 28.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 2 (b) 3 (c) 4 (d) 6
  29. 29.💪 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).
  30. 30.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 90px;
      justify-content: flex-end;
    }
    Inside are 2 boxes, each 40px wide (no margins).
  31. 31.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 300px;
      padding: 10px;
      border: 3px solid black;
      margin: 5px;
    }
  32. 32.🌈 Which colour is #000000? (a) bright green (b) magenta (c) white (d) black
  33. 33.Which of these does HTML do? (a) changes the text size (b) reacts to a button click (c) rounds box corners (d) puts a picture on a page
  34. 34.📦 In the box model, which part is the gap to other boxes? (a) content (b) border (c) margin (d) padding
  35. 35.True or false: img is an id selector. (a) False (b) True
  36. 36.🖌️ What colour is behind the letters?
    li {
      background-color: black;
      text-align: right;
      color: purple;
      font-size: 12px;
    }
    (a) black (b) purple (c) red
  37. 37.✍️ How does a CSS comment start? (a) <!-- (b) /* (c) # (d) //
  38. 38.🌈 Which hex code is black? (a) #00ff00 (b) #ffff00 (c) #000000 (d) #ffffff
  39. 39.🎯 Which sign starts an id selector? (a) @ (b) . (c) & (d) #
  40. 40.🖌️ Which CSS property picks the font style? (a) font-size (b) font-weight (c) font-family (d) background-color

Answer key

  1. border
  2. False
  3. 1
  4. 116
  5. CSS
  6. magenta
  7. cyan
  8. an id selector
  9. red
  10. .
  11. an element selector
  12. font-style
  13. 4
  14. fits every screen
  15. False
  16. black
  17. .box
  18. blue
  19. <style>
  20. flex-start
  21. Yes
  22. justify-content
  23. .box
  24. the later one
  25. 70
  26. in the middle
  27. False
  28. 3
  29. 30
  30. 10
  31. 326
  32. black
  33. puts a picture on a page
  34. margin
  35. False
  36. black
  37. /*
  38. #000000
  39. #
  40. font-family

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