← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 924 · 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.🌈 In #ad0000 the red part is the hex number ad. What is it as a normal number?
  2. 2.🖌️ Where does the text sit on its line?
    h2 {
      font-size: 40px;
      text-align: center;
      color: blue;
      background-color: red;
    }
    (a) on the right (b) on the left (c) in the middle
  3. 3.🎯 What kind of selector is #end? (a) a class selector (b) an id selector (c) an element selector
  4. 4.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 24px;
      }
    }
  5. 5.🎯 Which element does the selector .big style? (a) <h2 class="red"> (b) <h2 class="big"> (c) <li class="box"> (d) <h2 id="big">
  6. 6.🎯 Can many elements share the same class? (a) No (b) Yes
  7. 7.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 18px;
      }
    }
  8. 8.✍️ What value is given to margin in this rule?
    h1 {
      font-weight: bold;
      width: 300px;
      font-style: italic;
      margin: 10px;
    }
    (a) 10px (b) margin (c) bold (d) 8px
  9. 9.💪 Which justify-content value packs boxes at the end? (a) flex-start (b) flex-end (c) center (d) space-between
  10. 10.🎯 Which CSS selector matches this element?
    <h1 class="note" id="hero">Hello</h1>
    (a) .hero (b) #top (c) h1 (d) #note
  11. 11.✍️ What is the selector in this CSS rule?
    h2 {
      font-weight: bold;
      font-size: 20px;
      padding: 8px;
    }
    (a) h2 (b) font-weight (c) h1 (d) 20px
  12. 12.🌈 Which colour of light is strongest in rgb(88, 150, 83)? (a) blue (b) green (c) red
  13. 13.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      margin: 10px;
    }
  14. 14.💪 Which justify-content value equal gaps, none at ends? (a) center (b) flex-start (c) flex-end (d) space-between
  15. 15.🖌️ Where does the text sit on its line?
    h1 {
      text-align: center;
      font-size: 24px;
      color: black;
      background-color: yellow;
    }
    (a) on the right (b) in the middle (c) on the left
  16. 16.🖌️ What colour is behind the letters?
    h1 {
      font-size: 16px;
      text-align: center;
      background-color: green;
      color: black;
    }
    (a) black (b) purple (c) green
  17. 17.⚖️ What colour is the text of this element?
    <h1 class="big" id="end">Hi</h1>
    CSS:
    h1 { color: yellow; }
    .big { color: blue; }
    (a) blue (b) yellow (c) white (d) green
  18. 18.Which of these does HTML do? (a) reacts to a button click (b) changes the page live (c) makes headings and lists (d) adds space around boxes
  19. 19.⚖️ What colour is the text of this element?
    <p class="big" id="main">Hi</p>
    CSS:
    .big { color: purple; }
    .big { color: white; }
    (a) orange (b) purple (c) white (d) blue
  20. 20.📱 Which tag helps phones show a page at the right size? (a) the hr tag (b) the viewport meta tag (c) the br tag (d) the title tag
  21. 21.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 180px;
      justify-content: flex-start;
    }
    Inside are 3 boxes, each 50px wide (no margins).
  22. 22.✍️ What is the selector in this CSS rule?
    h1 {
      width: 300px;
      color: red;
      background-color: yellow;
    }
    (a) width (b) red (c) p (d) h1
  23. 23.🌈 Which colour is #00ff00? (a) bright green (b) magenta (c) white (d) black
  24. 24.🔍 Which is the odd one out? (a) shows a pop-up message (b) gives the page structure (c) makes a form box (d) puts a picture on a page
  25. 25.💪 Which flexbox property picks row or column? (a) justify-content (b) flex-direction (c) align-items (d) gap
  26. 26.📱 The screen is 375px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 12px;
      }
    }
    (a) No (b) Yes
  27. 27.🎯 What kind of selector is #top? (a) an id selector (b) an element selector (c) a class selector
  28. 28.True or false: h1 is an id selector. (a) True (b) False
  29. 29.What does background-color do? (a) centres a heading (b) colours behind the text (c) makes letters bigger (d) sets the letter colour
  30. 30.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 140px;
      padding: 10px;
      border: 5px solid black;
      margin: 0px;
    }
  31. 31.⚖️ Which selector is the strongest? (a) an id selector (b) an element selector (c) a class selector
  32. 32.✍️ What value is given to background-color in this rule?
    h1 {
      background-color: yellow;
      color: red;
    }
    (a) background-color (b) 10px (c) yellow (d) 8px
  33. 33.🌈 Hex digits go 0 to 9, then A to which letter? (a) F (b) Z (c) G (d) J
  34. 34.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 170px;
      padding: 15px;
      border: 5px solid black;
      margin: 0px;
    }
  35. 35.True or false: img is a class selector. (a) True (b) False
  36. 36.⚖️ What colour is the text of this element?
    <p class="menu" id="top">Hi</p>
    CSS:
    #top { color: black; }
    #top { color: blue; }
    (a) blue (b) red (c) black (d) yellow
  37. 37.🌈 Which colour of light is strongest in rgb(159, 16, 104)? (a) red (b) green (c) blue
  38. 38.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 20px;
      }
    }
  39. 39.⚖️ What colour is the text of this element?
    <h2 class="big" id="logo">Hi</h2>
    CSS:
    .big { color: blue; }
    .big { color: green; }
    (a) white (b) green (c) blue (d) black
  40. 40.🧩 Which language makes headings and lists? (a) JavaScript (b) CSS (c) HTML

Answer key

  1. 173
  2. in the middle
  3. an id selector
  4. 20
  5. <h2 class="big">
  6. Yes
  7. 18
  8. 10px
  9. flex-end
  10. h1
  11. h2
  12. green
  13. 1
  14. space-between
  15. in the middle
  16. green
  17. blue
  18. makes headings and lists
  19. white
  20. the viewport meta tag
  21. 30
  22. h1
  23. bright green
  24. shows a pop-up message
  25. flex-direction
  26. Yes
  27. an id selector
  28. False
  29. colours behind the text
  30. 170
  31. an id selector
  32. yellow
  33. F
  34. 210
  35. False
  36. blue
  37. red
  38. 16
  39. green
  40. HTML

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