← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 94 · 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 colour are the letters?
    p {
      font-size: 36px;
      text-align: center;
      background-color: red;
      color: blue;
    }
    (a) blue (b) orange (c) red
  2. 2.⚖️ What colour is the text of this element?
    <h2 class="star" id="logo">Hi</h2>
    CSS:
    .star { color: orange; }
    #logo { color: white; }
    h2 { color: red; }
    (a) white (b) red (c) yellow (d) orange
  3. 3.📱 The screen is 820px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 10px;
      }
    }
    (a) No (b) Yes
  4. 4.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 300px;
      padding: 10px;
      border: 1px solid black;
      margin: 5px;
    }
  5. 5.✍️ Which property is set to bold in this rule?
    p {
      margin: 10px;
      font-weight: bold;
    }
    (a) font-weight (b) bold (c) width (d) border
  6. 6.🌈 Which hex code is red? (a) #ff0000 (b) #00ffff (c) #0000ff (d) #00ff00
  7. 7.🎯 Which sign starts a class selector? (a) & (b) @ (c) . (d) #
  8. 8.📱 The screen is 320px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 20px;
      }
    }
    (a) Yes (b) No
  9. 9.What does justify-content: center do? (a) packs boxes at the end (b) equal gaps, none at ends (c) packs boxes at the start (d) puts boxes in the middle
  10. 10.🌈 Which colour is #ffff00? (a) white (b) blue (c) bright green (d) yellow
  11. 11.📱 What does a media query check? (a) the time of day (b) the screen width (c) the battery level (d) the page title
  12. 12.⚖️ What colour is the text of this element?
    <h1 class="star" id="logo">Hi</h1>
    CSS:
    h1 { color: blue; }
    h1 { color: black; }
    (a) blue (b) red (c) white (d) black
  13. 13.⚖️ What colour is the text of this element?
    <p class="big" id="end">Hi</p>
    CSS:
    p { color: yellow; }
    p { color: green; }
    (a) white (b) yellow (c) red (d) green
  14. 14.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) neither (c) the later one (d) the first one
  15. 15.🎯 What kind of selector is #top? (a) a class selector (b) an id selector (c) an element selector
  16. 16.⚖️ Which selector is the strongest? (a) an id selector (b) a class selector (c) an element selector
  17. 17.🎯 What kind of selector is .star? (a) a class selector (b) an id selector (c) an element selector
  18. 18.Which of these is padding? (a) a solid or dotted edge (b) the line round the box (c) space inside the border (d) the text or picture
  19. 19.🌈 In #7e0000 the red part is the hex number 7e. What is it as a normal number?
  20. 20.🎯 Which CSS selector matches this element?
    <div class="big" id="main">Hello</div>
    (a) span (b) #big (c) .main (d) .big
  21. 21.True or false: padding is the gap to other boxes. (a) False (b) True
  22. 22.⚖️ What colour is the text of this element?
    <p class="menu" id="top">Hi</p>
    CSS:
    .menu { color: orange; }
    .menu { color: green; }
    (a) orange (b) yellow (c) blue (d) green
  23. 23.⚖️ What colour is the text of this element?
    <h2 class="star" id="top">Hi</h2>
    CSS:
    .star { color: orange; }
    .star { color: green; }
    (a) green (b) orange (c) white (d) blue
  24. 24.Which of these is margin? (a) space outside the border (b) the gap round content (c) the line round the box (d) a solid or dotted edge
  25. 25.True or false: padding is the gap round content. (a) False (b) True
  26. 26.Which of these does CSS do? (a) makes a link (b) sets colours and fonts (c) makes headings and lists (d) checks a quiz answer
  27. 27.🌈 In #0000d4 the blue part is the hex number d4. What is it as a normal number?
  28. 28.🎯 What kind of selector is #hero? (a) an id selector (b) an element selector (c) a class selector
  29. 29.🌈 Which colour is rgb(0, 255, 0)? (a) black (b) bright green (c) red (d) blue
  30. 30.⚖️ What colour is the text of this element?
    <p class="menu" id="hero">Hi</p>
    CSS:
    #hero { color: white; }
    p { color: blue; }
    .menu { color: black; }
    (a) orange (b) white (c) blue (d) black
  31. 31.✍️ What value is given to background-color in this rule?
    p {
      background-color: yellow;
      font-weight: bold;
      font-style: italic;
      margin: 10px;
    }
    (a) 10px (b) background-color (c) yellow (d) 8px
  32. 32.⚖️ What colour is the text of this element?
    <p class="red" id="logo">Hi</p>
    CSS:
    #logo { color: yellow; }
    .red { color: orange; }
    (a) yellow (b) blue (c) orange (d) purple
  33. 33.✍️ What value is given to width in this rule?
    li {
      color: red;
      font-style: italic;
      font-weight: bold;
      width: 300px;
    }
    (a) italic (b) red (c) width (d) 300px
  34. 34.🧩 Which language counts down a timer? (a) HTML (b) CSS (c) JavaScript
  35. 35.Which of these does CSS do? (a) changes the text size (b) changes the page live (c) makes a form box (d) shows a pop-up message
  36. 36.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 120px;
      padding: 10px;
      border: 4px solid black;
      margin: 10px;
    }
  37. 37.🌈 Hex digits go 0 to 9, then A to which letter? (a) F (b) J (c) G (d) Z
  38. 38.🔍 Which is the odd one out? (a) adds space around boxes (b) lays out the page (c) sets colours and fonts (d) reacts to a button click
  39. 39.🎯 Which CSS selector matches this element?
    <li class="big" id="logo">Hello</li>
    (a) #big (b) .logo (c) .big (d) div
  40. 40.✍️ How does a CSS comment start? (a) <!-- (b) // (c) /* (d) #

Answer key

  1. blue
  2. white
  3. No
  4. 332
  5. font-weight
  6. #ff0000
  7. .
  8. No
  9. puts boxes in the middle
  10. yellow
  11. the screen width
  12. black
  13. green
  14. the later one
  15. an id selector
  16. an id selector
  17. a class selector
  18. space inside the border
  19. 126
  20. .big
  21. False
  22. green
  23. green
  24. space outside the border
  25. True
  26. sets colours and fonts
  27. 212
  28. an id selector
  29. bright green
  30. white
  31. yellow
  32. yellow
  33. 300px
  34. JavaScript
  35. changes the text size
  36. 168
  37. F
  38. reacts to a button click
  39. .big
  40. /*

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