← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 643 · 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.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 110px;
      padding: 5px;
      border: 2px solid black;
      margin: 20px;
    }
  2. 2.🎯 Which element does the selector div style? (a) <p class="menu"> (b) <div class="menu"> (c) <span> (d) <h1 id="top">
  3. 3.🔍 Which is the odd one out? (a) counts down a timer (b) shows a pop-up message (c) makes headings and lists (d) reacts to a button click
  4. 4.🔍 Which is the odd one out? (a) reacts to a button click (b) changes the text size (c) sets colours and fonts (d) rounds box corners
  5. 5.⚖️ What colour is the text of this element?
    <p class="big" id="main">Hi</p>
    CSS:
    #main { color: purple; }
    p { color: blue; }
    (a) white (b) blue (c) yellow (d) purple
  6. 6.🎯 Which element does the selector h1 style? (a) <h1 class="box"> (b) <div id="end"> (c) <h2> (d) <li class="box">
  7. 7.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 320px;
      justify-content: center;
    }
    Inside are 2 boxes, each 80px wide (no margins).
  8. 8.🌈 Which colour is #000000? (a) red (b) yellow (c) black (d) blue
  9. 9.What does justify-content: space-between do? (a) puts boxes in the middle (b) packs boxes at the start (c) equal gaps, none at ends (d) packs boxes at the end
  10. 10.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 320px;
      justify-content: flex-start;
    }
    Inside are 3 boxes, each 100px wide (no margins).
  11. 11.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
  12. 12.🌈 Which hex code is white? (a) #ffff00 (b) #00ff00 (c) #ff0000 (d) #ffffff
  13. 13.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 100px;
      padding: 30px;
      border: 1px solid black;
      margin: 15px;
    }
  14. 14.🖌️ Which CSS property centres a heading? (a) color (b) font-family (c) text-align (d) font-weight
  15. 15.⚖️ What colour is the text of this element?
    <h2 class="menu" id="intro">Hi</h2>
    CSS:
    h2 { color: red; }
    #intro { color: purple; }
    (a) yellow (b) red (c) purple (d) orange
  16. 16.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 14px;
      }
    }
  17. 17.🧩 Which language rounds box corners? (a) JavaScript (b) HTML (c) CSS
  18. 18.True or false: padding is space outside the border. (a) False (b) True
  19. 19.🎨 A CSS file usually ends with which extension? (a) .png (b) .html (c) .css (d) .js
  20. 20.✍️ What is the selector in this CSS rule?
    .note {
      padding: 8px;
      font-style: italic;
      font-size: 20px;
    }
    (a) padding (b) italic (c) #top (d) .note
  21. 21.✍️ What is the selector in this CSS rule?
    .box {
      background-color: yellow;
      padding: 8px;
    }
    (a) background-color (b) 8px (c) h2 (d) .box
  22. 22.🎯 How many elements on a page should have the same id? (a) 5 (b) 2 (c) any number (d) 1
  23. 23.✍️ Which property is set to italic in this rule?
    h1 {
      font-style: italic;
      border: 2px solid;
    }
    (a) font-size (b) font-style (c) italic (d) color
  24. 24.🌈 Which colour is #00ff00? (a) cyan (b) bright green (c) white (d) yellow
  25. 25.True or false: .menu is an id selector. (a) True (b) False
  26. 26.✍️ Which property is set to red in this rule?
    h2 {
      color: red;
      padding: 8px;
      background-color: yellow;
    }
    (a) font-size (b) red (c) text-align (d) color
  27. 27.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 10px;
      }
    }
  28. 28.What does justify-content: flex-end do? (a) puts boxes in the middle (b) packs boxes at the end (c) packs boxes at the start (d) equal gaps, none at ends
  29. 29.🖌️ How big is the text, in px?
    h1 {
      text-align: center;
      background-color: green;
      font-size: 40px;
      color: red;
    }
  30. 30.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 240px;
      justify-content: center;
    }
    Inside are 2 boxes, each 100px wide (no margins).
  31. 31.True or false: JavaScript makes a link. (a) True (b) False
  32. 32.📦 In the box model, which part is the gap to other boxes? (a) padding (b) margin (c) content (d) border
  33. 33.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
  34. 34.🎯 Which CSS selector matches this element?
    <p class="star" id="main">Hello</p>
    (a) #star (b) .main (c) p (d) #logo
  35. 35.🎨 One CSS file can style how many pages? (a) only one image (b) many pages (c) no pages (d) only one word
  36. 36.🌈 Which hex code is cyan? (a) #ff0000 (b) #00ffff (c) #ffffff (d) #ffff00
  37. 37.True or false: padding is the line round the box. (a) False (b) True
  38. 38.🖌️ What colour is behind the letters?
    h2 {
      font-size: 12px;
      text-align: right;
      background-color: purple;
      color: white;
    }
    (a) white (b) blue (c) purple
  39. 39.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
  40. 40.True or false: the border is a solid or dotted edge. (a) True (b) False

Answer key

  1. 124
  2. <div class="menu">
  3. makes headings and lists
  4. reacts to a button click
  5. purple
  6. <h1 class="box">
  7. 80
  8. black
  9. equal gaps, none at ends
  10. 20
  11. an id selector
  12. #ffffff
  13. 162
  14. text-align
  15. purple
  16. 12
  17. CSS
  18. False
  19. .css
  20. .note
  21. .box
  22. 1
  23. font-style
  24. bright green
  25. False
  26. color
  27. 10
  28. packs boxes at the end
  29. 40
  30. 20
  31. False
  32. margin
  33. an element selector
  34. p
  35. many pages
  36. #00ffff
  37. False
  38. purple
  39. puts boxes in the middle
  40. True

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