← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 677 · 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.What does font-family do? (a) makes letters bigger (b) sets the letter colour (c) centres a heading (d) picks the font style
  2. 2.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      text-align: center;
      color: red;
    }
  3. 3.🖌️ What colour are the letters?
    h2 {
      background-color: blue;
      color: green;
      font-size: 36px;
      text-align: left;
    }
    (a) blue (b) purple (c) green
  4. 4.🎯 Which sign starts a class selector? (a) # (b) . (c) @ (d) &
  5. 5.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 190px;
      padding: 20px;
      border: 3px solid black;
      margin: 10px;
    }
  6. 6.📱 The screen is 700px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 18px;
      }
    }
    (a) Yes (b) No
  7. 7.🎯 Which CSS selector matches this element?
    <p class="menu" id="hero">Hello</p>
    (a) #menu (b) p (c) #top (d) h1
  8. 8.🌈 Which colour of light is strongest in rgb(37, 74, 221)? (a) red (b) blue (c) green
  9. 9.🎨 Which attribute adds CSS inside one tag? (a) style (b) href (c) alt (d) src
  10. 10.🔍 Which is the odd one out? (a) changes the text size (b) changes the page live (c) adds space around boxes (d) lays out the page
  11. 11.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 210px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 80px wide (no margins).
  12. 12.True or false: JavaScript counts down a timer. (a) False (b) True
  13. 13.⚖️ What colour is the text of this element?
    <h2 class="red" id="end">Hi</h2>
    CSS:
    #end { color: red; }
    #end { color: black; }
    (a) blue (b) yellow (c) red (d) black
  14. 14.🌈 Which colour is #ffff00? (a) blue (b) bright green (c) yellow (d) white
  15. 15.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 14px;
      }
    }
  16. 16.🌈 Which hex code is blue? (a) #ff00ff (b) #ffffff (c) #0000ff (d) #ff0000
  17. 17.⚖️ What colour is the text of this element?
    <p class="note" id="main">Hi</p>
    CSS:
    .note { color: black; }
    #main { color: purple; }
    p { color: yellow; }
    (a) yellow (b) black (c) purple (d) orange
  18. 18.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      text-align: center;
      width: 300px;
    }
  19. 19.🎯 Which element does the selector #logo style? (a) <span class="red"> (b) <div id="end"> (c) <div id="logo"> (d) <div class="logo">
  20. 20.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 32px;
      }
    }
    (a) Yes (b) No
  21. 21.🧩 Which language reacts to a button click? (a) HTML (b) CSS (c) JavaScript
  22. 22.✍️ What is the selector in this CSS rule?
    li {
      border: 2px solid;
      padding: 8px;
      font-size: 20px;
    }
    (a) 8px (b) li (c) border (d) body
  23. 23.✍️ How does a CSS comment start? (a) # (b) // (c) /* (d) <!--
  24. 24.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 160px;
      padding: 25px;
      border: 3px solid black;
      margin: 5px;
    }
  25. 25.🌈 Which colour of light is strongest in rgb(33, 229, 122)? (a) blue (b) red (c) green
  26. 26.🎯 What kind of selector is img? (a) a class selector (b) an element selector (c) an id selector
  27. 27.⚖️ What colour is the text of this element?
    <h1 class="note" id="intro">Hi</h1>
    CSS:
    h1 { color: orange; }
    .note { color: blue; }
    (a) green (b) orange (c) blue (d) white
  28. 28.✍️ CSS declarations go inside which brackets? (a) < > (b) { } (c) [ ] (d) ( )
  29. 29.⚖️ What colour is the text of this element?
    <h2 class="big" id="hero">Hi</h2>
    CSS:
    h2 { color: white; }
    h2 { color: black; }
    (a) black (b) white (c) blue (d) green
  30. 30.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 60px;
      padding: 25px;
      border: 5px solid black;
      margin: 10px;
    }
  31. 31.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) black (c) blue (d) red
  32. 32.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      border: 2px solid;
      font-size: 20px;
    }
  33. 33.⚖️ Which selector is the strongest? (a) an id selector (b) a class selector (c) an element selector
  34. 34.🎯 What kind of selector is .star? (a) an id selector (b) an element selector (c) a class selector
  35. 35.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 28px;
      }
    }
  36. 36.⚖️ What colour is the text of this element?
    <h2 class="box" id="hero">Hi</h2>
    CSS:
    .box { color: orange; }
    h2 { color: yellow; }
    #hero { color: black; }
    (a) orange (b) black (c) blue (d) yellow
  37. 37.🎯 Which CSS selector matches this element?
    <li class="red" id="intro">Hello</li>
    (a) div (b) .intro (c) #red (d) .red
  38. 38.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 170px;
      padding: 15px;
      border: 4px solid black;
      margin: 15px;
    }
  39. 39.🖌️ What colour is behind the letters?
    h2 {
      text-align: right;
      font-size: 16px;
      color: purple;
      background-color: yellow;
    }
    (a) yellow (b) purple (c) red
  40. 40.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      font-size: 20px;
      font-weight: bold;
      color: red;
    }

Answer key

  1. picks the font style
  2. 2
  3. green
  4. .
  5. 236
  6. No
  7. p
  8. blue
  9. style
  10. changes the page live
  11. 50
  12. True
  13. black
  14. yellow
  15. 14
  16. #0000ff
  17. purple
  18. 2
  19. <div id="logo">
  20. No
  21. JavaScript
  22. li
  23. /*
  24. 226
  25. green
  26. an element selector
  27. blue
  28. { }
  29. black
  30. 120
  31. red
  32. 2
  33. an id selector
  34. a class selector
  35. 28
  36. black
  37. .red
  38. 238
  39. yellow
  40. 3

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