← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 418 · 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 is the selector in this CSS rule?
    li {
      border: 2px solid;
      font-weight: bold;
      font-style: italic;
    }
    (a) bold (b) li (c) body (d) border
  2. 2.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 190px;
      padding: 10px;
      border: 2px solid black;
      margin: 15px;
    }
  3. 3.🌈 Which colour is rgb(0, 255, 0)? (a) red (b) bright green (c) yellow (d) white
  4. 4.📱 What does a media query check? (a) the battery level (b) the time of day (c) the screen width (d) the page title
  5. 5.✍️ How many declarations (property: value pairs) are in this rule?
    li {
      color: red;
      background-color: yellow;
    }
  6. 6.🌈 In #460000 the red part is the hex number 46. What is it as a normal number?
  7. 7.📱 The screen is 320px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 18px;
      }
    }
    (a) Yes (b) No
  8. 8.🖌️ How big is the text, in px?
    h2 {
      text-align: right;
      color: yellow;
      background-color: red;
      font-size: 16px;
    }
  9. 9.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 100px;
      padding: 10px;
      border: 5px solid black;
      margin: 20px;
    }
  10. 10.🌈 Which colour is #ffffff? (a) bright green (b) white (c) red (d) magenta
  11. 11.🖌️ How big is the text, in px?
    p {
      text-align: right;
      color: yellow;
      background-color: red;
      font-size: 24px;
    }
  12. 12.✍️ Which property is set to 20px in this rule?
    li {
      font-style: italic;
      text-align: center;
      font-weight: bold;
      font-size: 20px;
    }
    (a) 20px (b) font-size (c) text-align (d) background-color
  13. 13.🎯 What kind of selector is .card? (a) an element selector (b) a class selector (c) an id selector
  14. 14.⚖️ What colour is the text of this element?
    <h2 class="star" id="hero">Hi</h2>
    CSS:
    .star { color: blue; }
    .star { color: green; }
    (a) yellow (b) orange (c) green (d) blue
  15. 15.🔍 Which is the odd one out? (a) gives the page structure (b) makes headings and lists (c) makes a form box (d) counts down a timer
  16. 16.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 14px;
      }
    }
  17. 17.🎨 One CSS file can style how many pages? (a) only one image (b) only one word (c) many pages (d) no pages
  18. 18.🖌️ Which CSS property sets the letter colour? (a) font-family (b) text-align (c) font-size (d) color
  19. 19.⚖️ What colour is the text of this element?
    <p class="star" id="main">Hi</p>
    CSS:
    #main { color: red; }
    #main { color: black; }
    (a) yellow (b) red (c) black (d) white
  20. 20.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
  21. 21.✍️ What is the selector in this CSS rule?
    .box {
      margin: 10px;
      padding: 8px;
      font-size: 20px;
      width: 300px;
    }
    (a) h2 (b) .box (c) margin (d) 8px
  22. 22.📱 min-width: 800px applies when the screen is ___. (a) exactly 100px (b) turned off (c) 800px or wider (d) 800px or narrower
  23. 23.🎯 Which CSS selector matches this element?
    <p class="star" id="intro">Hello</p>
    (a) #main (b) .star (c) #star (d) .intro
  24. 24.💪 Which flexbox property turns on flexbox? (a) flex-direction (b) justify-content (c) display: flex (d) gap
  25. 25.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      width: 300px;
      font-style: italic;
      padding: 8px;
    }
  26. 26.What does justify-content: space-between do? (a) packs boxes at the end (b) equal gaps, none at ends (c) puts boxes in the middle (d) packs boxes at the start
  27. 27.🎯 What kind of selector is .menu? (a) an id selector (b) a class selector (c) an element selector
  28. 28.⚖️ What colour is the text of this element?
    <p class="note" id="end">Hi</p>
    CSS:
    .note { color: red; }
    .note { color: black; }
    (a) purple (b) red (c) blue (d) black
  29. 29.✍️ Which property is set to 300px in this rule?
    .note {
      font-weight: bold;
      width: 300px;
      margin: 10px;
      color: red;
    }
    (a) 300px (b) font-style (c) color (d) width
  30. 30.🎯 Which element does the selector .red style? (a) <div class="red"> (b) <div id="red"> (c) <span class="star"> (d) <div class="box">
  31. 31.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      border: 2px solid;
    }
  32. 32.🧩 Which language makes a link? (a) HTML (b) JavaScript (c) CSS
  33. 33.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 210px;
      justify-content: flex-start;
    }
    Inside are 3 boxes, each 50px wide (no margins).
  34. 34.📱 The screen is 375px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 20px;
      }
    }
    (a) No (b) Yes
  35. 35.⚖️ What colour is the text of this element?
    <p class="big" id="top">Hi</p>
    CSS:
    #top { color: white; }
    #top { color: yellow; }
    (a) yellow (b) orange (c) white (d) blue
  36. 36.🎯 What kind of selector is body? (a) an id selector (b) an element selector (c) a class selector
  37. 37.📱 The screen is 320px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 20px;
      }
    }
    (a) No (b) Yes
  38. 38.Which of these is the content? (a) the gap round content (b) space inside the border (c) the gap to other boxes (d) the text or picture
  39. 39.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 50px;
      padding: 15px;
      border: 2px solid black;
      margin: 5px;
    }
  40. 40.True or false: CSS counts down a timer. (a) True (b) False

Answer key

  1. li
  2. 244
  3. bright green
  4. the screen width
  5. 2
  6. 70
  7. No
  8. 16
  9. 170
  10. white
  11. 24
  12. font-size
  13. a class selector
  14. green
  15. counts down a timer
  16. 14
  17. many pages
  18. color
  19. black
  20. an id selector
  21. .box
  22. 800px or wider
  23. .star
  24. display: flex
  25. 3
  26. equal gaps, none at ends
  27. a class selector
  28. black
  29. width
  30. <div class="red">
  31. 1
  32. HTML
  33. 60
  34. Yes
  35. yellow
  36. an element selector
  37. Yes
  38. the text or picture
  39. 94
  40. False

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