← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 296 · 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 is the text of this element?
    <p class="star" id="top">Hi</p>
    CSS:
    #top { color: blue; }
    #top { color: yellow; }
    (a) blue (b) black (c) yellow (d) purple
  2. 2.🧩 Which language puts a picture on a page? (a) JavaScript (b) CSS (c) HTML
  3. 3.✍️ What is the selector in this CSS rule?
    h2 {
      border: 2px solid;
      padding: 8px;
      width: 300px;
      background-color: yellow;
    }
    (a) 8px (b) h1 (c) h2 (d) border
  4. 4.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 22px;
      }
    }
  5. 5.🖌️ Where does the text sit on its line?
    h2 {
      color: red;
      text-align: right;
      background-color: green;
      font-size: 24px;
    }
    (a) on the left (b) in the middle (c) on the right
  6. 6.🌈 Which colour is rgb(0, 0, 255)? (a) magenta (b) white (c) bright green (d) blue
  7. 7.🖌️ Which CSS property sets the letter colour? (a) font-family (b) background-color (c) color (d) font-size
  8. 8.🌈 In #000035 the blue part is the hex number 35. What is it as a normal number?
  9. 9.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      padding: 8px;
      font-size: 20px;
    }
  10. 10.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 40px;
      padding: 30px;
      border: 4px solid black;
      margin: 15px;
    }
  11. 11.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 280px;
      justify-content: center;
    }
    Inside are 4 boxes, each 40px wide (no margins).
  12. 12.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 90px;
      padding: 15px;
      border: 2px solid black;
      margin: 20px;
    }
  13. 13.⚖️ What colour is the text of this element?
    <p class="box" id="main">Hi</p>
    CSS:
    #main { color: orange; }
    #main { color: black; }
    (a) black (b) purple (c) orange (d) green
  14. 14.🎯 Which CSS selector matches this element?
    <li class="red" id="logo">Hello</li>
    (a) #red (b) .logo (c) #end (d) .red
  15. 15.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 20px;
      }
    }
  16. 16.🌈 In #rrggbb, which colour do the first two digits give? (a) black (b) blue (c) red (d) green
  17. 17.🎨 One CSS file can style how many pages? (a) no pages (b) many pages (c) only one image (d) only one word
  18. 18.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 26px;
      }
    }
  19. 19.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
  20. 20.⚖️ What colour is the text of this element?
    <h2 class="red" id="logo">Hi</h2>
    CSS:
    .red { color: green; }
    .red { color: yellow; }
    (a) blue (b) red (c) green (d) yellow
  21. 21.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 80px;
      padding: 30px;
      border: 3px solid black;
      margin: 0px;
    }
  22. 22.📱 The screen is 700px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 6px;
      }
    }
    (a) No (b) Yes
  23. 23.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 40px;
      padding: 25px;
      border: 2px solid black;
      margin: 5px;
    }
  24. 24.What does font-family do? (a) colours behind the text (b) picks the font style (c) centres a heading (d) makes letters bigger
  25. 25.🔍 Which is the odd one out? (a) checks a quiz answer (b) shows a pop-up message (c) counts down a timer (d) puts a picture on a page
  26. 26.🎯 Which element does the selector li style? (a) <li class="menu"> (b) <span class="menu"> (c) <div> (d) <p id="top">
  27. 27.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 26px;
      }
    }
  28. 28.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 120px;
      justify-content: space-between;
    }
    Inside are 2 boxes, each 50px wide (no margins).
  29. 29.True or false: CSS makes headings and lists. (a) False (b) True
  30. 30.🎯 What kind of selector is h1? (a) a class selector (b) an element selector (c) an id selector
  31. 31.📱 The screen is 1100px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 22px;
      }
    }
    (a) No (b) Yes
  32. 32.🖌️ What colour are the letters?
    h2 {
      font-size: 12px;
      background-color: green;
      text-align: center;
      color: black;
    }
    (a) black (b) green (c) orange
  33. 33.🖌️ Where does the text sit on its line?
    li {
      font-size: 16px;
      text-align: right;
      color: black;
      background-color: orange;
    }
    (a) on the right (b) in the middle (c) on the left
  34. 34.💪 Which justify-content value equal gaps, none at ends? (a) flex-end (b) flex-start (c) space-between (d) center
  35. 35.🎨 Which attribute adds CSS inside one tag? (a) src (b) href (c) style (d) alt
  36. 36.📦 In the box model, which part is a solid or dotted edge? (a) padding (b) content (c) border (d) margin
  37. 37.True or false: CSS lays out the page. (a) True (b) False
  38. 38.🎯 What kind of selector is .card? (a) a class selector (b) an element selector (c) an id selector
  39. 39.🖌️ Where does the text sit on its line?
    h2 {
      text-align: left;
      color: green;
      font-size: 24px;
      background-color: black;
    }
    (a) in the middle (b) on the left (c) on the right
  40. 40.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 110px;
      padding: 5px;
      border: 5px solid black;
      margin: 10px;
    }

Answer key

  1. yellow
  2. HTML
  3. h2
  4. 16
  5. on the right
  6. blue
  7. color
  8. 53
  9. 2
  10. 138
  11. 60
  12. 164
  13. black
  14. .red
  15. 24
  16. red
  17. many pages
  18. 26
  19. an id selector
  20. yellow
  21. 146
  22. Yes
  23. 104
  24. picks the font style
  25. puts a picture on a page
  26. <li class="menu">
  27. 26
  28. 20
  29. False
  30. an element selector
  31. Yes
  32. black
  33. on the right
  34. space-between
  35. style
  36. border
  37. True
  38. a class selector
  39. on the left
  40. 150

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