← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 291 · 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.🌈 Which hex code is blue? (a) #ff0000 (b) #ff00ff (c) #ffff00 (d) #0000ff
  2. 2.📱 The screen is 700px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 32px;
      }
    }
    (a) No (b) Yes
  3. 3.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 26px;
      }
    }
  4. 4.⚖️ What colour is the text of this element?
    <h2 class="red" id="intro">Hi</h2>
    CSS:
    #intro { color: green; }
    h2 { color: orange; }
    .red { color: black; }
    (a) yellow (b) green (c) black (d) orange
  5. 5.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 360px;
      justify-content: center;
    }
    Inside are 2 boxes, each 100px wide (no margins).
  6. 6.Which of these does CSS do? (a) reacts to a button click (b) checks a quiz answer (c) sets colours and fonts (d) makes a form box
  7. 7.🧩 Which language makes a form box? (a) JavaScript (b) CSS (c) HTML
  8. 8.⚖️ What colour is the text of this element?
    <h1 class="box" id="top">Hi</h1>
    CSS:
    .box { color: blue; }
    h1 { color: yellow; }
    #top { color: black; }
    (a) blue (b) black (c) yellow (d) red
  9. 9.🖌️ Where does the text sit on its line?
    h2 {
      background-color: yellow;
      text-align: center;
      font-size: 20px;
      color: green;
    }
    (a) in the middle (b) on the left (c) on the right
  10. 10.🖌️ Where does the text sit on its line?
    h2 {
      font-size: 24px;
      text-align: center;
      background-color: orange;
      color: white;
    }
    (a) in the middle (b) on the right (c) on the left
  11. 11.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) exactly 1000px (c) turned off (d) 600px or narrower
  12. 12.📱 The screen is 700px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 18px;
      }
    }
    (a) No (b) Yes
  13. 13.🌈 Which hex code is cyan? (a) #00ff00 (b) #0000ff (c) #00ffff (d) #ff0000
  14. 14.💪 Which flexbox property sets space between boxes? (a) flex-direction (b) gap (c) justify-content (d) align-items
  15. 15.🎯 What kind of selector is #top? (a) an id selector (b) an element selector (c) a class selector
  16. 16.🎯 Which CSS selector matches this element?
    <span class="star" id="intro">Hello</span>
    (a) p (b) #intro (c) #star (d) #main
  17. 17.🖌️ What colour are the letters?
    h1 {
      color: green;
      background-color: orange;
      font-size: 40px;
      text-align: right;
    }
    (a) yellow (b) green (c) orange
  18. 18.⚖️ What colour is the text of this element?
    <p class="big" id="top">Hi</p>
    CSS:
    #top { color: red; }
    #top { color: green; }
    (a) black (b) green (c) red (d) white
  19. 19.Which of these does HTML do? (a) counts down a timer (b) shows a pop-up message (c) lays out the page (d) makes a link
  20. 20.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
  21. 21.📱 Which tag helps phones show a page at the right size? (a) the br tag (b) the viewport meta tag (c) the title tag (d) the hr tag
  22. 22.⚖️ What colour is the text of this element?
    <h2 class="note" id="logo">Hi</h2>
    CSS:
    h2 { color: red; }
    #logo { color: white; }
    .note { color: yellow; }
    (a) red (b) yellow (c) black (d) white
  23. 23.💪 Which justify-content value packs boxes at the end? (a) space-between (b) flex-end (c) center (d) flex-start
  24. 24.📱 What does a media query check? (a) the time of day (b) the screen width (c) the battery level (d) the page title
  25. 25.What does justify-content: space-between do? (a) puts boxes in the middle (b) packs boxes at the start (c) packs boxes at the end (d) equal gaps, none at ends
  26. 26.⚖️ What colour is the text of this element?
    <h2 class="star" id="logo">Hi</h2>
    CSS:
    .star { color: green; }
    #logo { color: red; }
    (a) green (b) purple (c) white (d) red
  27. 27.✍️ What value is given to font-style in this rule?
    body {
      font-style: italic;
      width: 300px;
      background-color: yellow;
    }
    (a) red (b) 20px (c) italic (d) font-style
  28. 28.True or false: margin is a solid or dotted edge. (a) True (b) False
  29. 29.📱 Responsive design means a page ___. (a) fits every screen (b) never changes (c) has no pictures (d) is only for laptops
  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: 250px;
      padding: 25px;
      border: 5px solid black;
      margin: 10px;
    }
  31. 31.✍️ How many declarations (property: value pairs) are in this rule?
    #top {
      font-weight: bold;
      border: 2px solid;
      text-align: center;
      width: 300px;
    }
  32. 32.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 12px;
      }
    }
  33. 33.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 18px;
      }
    }
  34. 34.🎯 Which sign starts a class selector? (a) @ (b) & (c) # (d) .
  35. 35.🔍 Which is the odd one out? (a) adds space around boxes (b) sets colours and fonts (c) puts a picture on a page (d) rounds box corners
  36. 36.🎯 Can many elements share the same class? (a) Yes (b) No
  37. 37.✍️ What is the selector in this CSS rule?
    li {
      width: 300px;
      text-align: center;
      background-color: yellow;
      border: 2px solid;
    }
    (a) li (b) width (c) body (d) center
  38. 38.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 18px;
      }
    }
  39. 39.📱 The screen is 820px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 18px;
      }
    }
    (a) Yes (b) No
  40. 40.🎯 What kind of selector is #main? (a) an id selector (b) an element selector (c) a class selector

Answer key

  1. #0000ff
  2. No
  3. 26
  4. green
  5. 80
  6. sets colours and fonts
  7. HTML
  8. black
  9. in the middle
  10. in the middle
  11. 600px or narrower
  12. No
  13. #00ffff
  14. gap
  15. an id selector
  16. #intro
  17. green
  18. green
  19. makes a link
  20. an element selector
  21. the viewport meta tag
  22. white
  23. flex-end
  24. the screen width
  25. equal gaps, none at ends
  26. red
  27. italic
  28. False
  29. fits every screen
  30. 310
  31. 4
  32. 12
  33. 18
  34. .
  35. puts a picture on a page
  36. Yes
  37. li
  38. 18
  39. No
  40. an id selector

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