← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 729 · 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 selector is the weakest? (a) an id selector (b) an element selector (c) a class selector
  2. 2.True or false: #top is an element selector. (a) False (b) True
  3. 3.⚖️ What colour is the text of this element?
    <p class="menu" id="top">Hi</p>
    CSS:
    p { color: blue; }
    #top { color: black; }
    .menu { color: purple; }
    (a) blue (b) black (c) white (d) purple
  4. 4.✍️ What value is given to border in this rule?
    .note {
      font-style: italic;
      margin: 10px;
      border: 2px solid;
    }
    (a) 2px solid (b) border (c) italic (d) 300px
  5. 5.📦 In the box model, which part is the gap round content? (a) border (b) margin (c) padding (d) content
  6. 6.⚖️ What colour is the text of this element?
    <h2 class="note" id="intro">Hi</h2>
    CSS:
    h2 { color: orange; }
    h2 { color: red; }
    (a) orange (b) blue (c) red (d) black
  7. 7.🌈 Which hex code is red? (a) #ff00ff (b) #0000ff (c) #ffff00 (d) #ff0000
  8. 8.🎯 Which CSS selector matches this element?
    <span class="note" id="end">Hello</span>
    (a) #note (b) span (c) .big (d) .end
  9. 9.💪 Which flexbox property spaces boxes along a row? (a) gap (b) align-items (c) justify-content (d) flex-direction
  10. 10.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 310px;
      justify-content: space-between;
    }
    Inside are 3 boxes, each 50px wide (no margins).
  11. 11.🌈 In #0b0000 the red part is the hex number 0b. What is it as a normal number?
  12. 12.💪 Which justify-content value equal gaps, none at ends? (a) space-between (b) flex-end (c) center (d) flex-start
  13. 13.🎯 What kind of selector is #end? (a) an id selector (b) a class selector (c) an element selector
  14. 14.⚖️ What colour is the text of this element?
    <h2 class="big" id="logo">Hi</h2>
    CSS:
    .big { color: orange; }
    .big { color: white; }
    (a) orange (b) white (c) red (d) blue
  15. 15.🎯 How many elements on a page should have the same id? (a) 2 (b) 5 (c) 1 (d) any number
  16. 16.🎯 What kind of selector is li? (a) a class selector (b) an element selector (c) an id selector
  17. 17.📱 The screen is 320px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 28px;
      }
    }
    (a) Yes (b) No
  18. 18.🔍 Which is the odd one out? (a) makes a link (b) puts a picture on a page (c) lays out the page (d) makes headings and lists
  19. 19.🧩 Which language shows a pop-up message? (a) HTML (b) CSS (c) JavaScript
  20. 20.📦 In the box model, which part is space inside the border? (a) content (b) border (c) margin (d) padding
  21. 21.🖌️ Where does the text sit on its line?
    h1 {
      font-size: 32px;
      color: white;
      text-align: right;
      background-color: black;
    }
    (a) on the right (b) on the left (c) in the middle
  22. 22.True or false: margin is space outside the border. (a) False (b) True
  23. 23.🖌️ What colour is behind the letters?
    li {
      color: green;
      background-color: purple;
      text-align: right;
      font-size: 24px;
    }
    (a) blue (b) green (c) purple
  24. 24.✍️ What is the selector in this CSS rule?
    p {
      font-weight: bold;
      border: 2px solid;
      background-color: yellow;
    }
    (a) .note (b) p (c) font-weight (d) 2px solid
  25. 25.True or false: margin is the gap round content. (a) True (b) False
  26. 26.🌈 Which colour of light is strongest in rgb(31, 173, 24)? (a) blue (b) green (c) red
  27. 27.🔍 Which is the odd one out? (a) checks a quiz answer (b) counts down a timer (c) shows a pop-up message (d) adds space around boxes
  28. 28.What does font-size do? (a) picks the font style (b) colours behind the text (c) makes the text bold (d) makes letters bigger
  29. 29.✍️ CSS declarations go inside which brackets? (a) { } (b) [ ] (c) ( ) (d) < >
  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 60px wide (no margins).
  31. 31.✍️ What value is given to color in this rule?
    #top {
      text-align: center;
      font-style: italic;
      color: red;
      width: 300px;
    }
    (a) 20px (b) color (c) center (d) red
  32. 32.💪 Which flexbox property picks row or column? (a) display: flex (b) gap (c) flex-direction (d) align-items
  33. 33.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 270px;
      padding: 10px;
      border: 4px solid black;
      margin: 20px;
    }
  34. 34.What does text-align do? (a) makes letters bigger (b) sets the letter colour (c) picks the font style (d) centres a heading
  35. 35.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 380px;
      justify-content: center;
    }
    Inside are 3 boxes, each 80px wide (no margins).
  36. 36.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 260px;
      justify-content: center;
    }
    Inside are 2 boxes, each 100px wide (no margins).
  37. 37.True or false: JavaScript puts a picture on a page. (a) True (b) False
  38. 38.📦 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;
    }
  39. 39.What does background-color do? (a) picks the font style (b) makes letters bigger (c) colours behind the text (d) sets the letter colour
  40. 40.🌈 Which hex code is bright green? (a) #0000ff (b) #00ffff (c) #ffffff (d) #00ff00

Answer key

  1. an element selector
  2. False
  3. black
  4. 2px solid
  5. padding
  6. red
  7. #ff0000
  8. span
  9. justify-content
  10. 80
  11. 11
  12. space-between
  13. an id selector
  14. white
  15. 1
  16. an element selector
  17. No
  18. lays out the page
  19. JavaScript
  20. padding
  21. on the right
  22. True
  23. purple
  24. p
  25. False
  26. green
  27. adds space around boxes
  28. makes letters bigger
  29. { }
  30. 60
  31. red
  32. flex-direction
  33. 338
  34. centres a heading
  35. 70
  36. 30
  37. False
  38. 128
  39. colours behind the text
  40. #00ff00

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