← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 15 · 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.True or false: .star is an id selector. (a) False (b) True
  2. 2.⚖️ What colour is the text of this element?
    <h1 class="note" id="logo">Hi</h1>
    CSS:
    h1 { color: purple; }
    #logo { color: red; }
    (a) red (b) orange (c) purple (d) green
  3. 3.✍️ What value is given to padding in this rule?
    p {
      font-size: 20px;
      padding: 8px;
    }
    (a) 8px (b) bold (c) 2px solid (d) padding
  4. 4.📱 Responsive design means a page ___. (a) has no pictures (b) never changes (c) fits every screen (d) is only for laptops
  5. 5.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 100px;
      padding: 25px;
      border: 1px solid black;
      margin: 0px;
    }
  6. 6.📱 max-width: 600px applies when the screen is ___. (a) turned off (b) 600px or narrower (c) 600px or wider (d) exactly 1000px
  7. 7.Which of these does CSS do? (a) sets colours and fonts (b) shows a pop-up message (c) changes the page live (d) checks a quiz answer
  8. 8.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
  9. 9.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the later one (b) the first one (c) neither (d) the shorter one
  10. 10.True or false: CSS reacts to a button click. (a) False (b) True
  11. 11.🌈 Which colour is rgb(255, 255, 0)? (a) red (b) yellow (c) white (d) magenta
  12. 12.🧩 Which language reacts to a button click? (a) CSS (b) JavaScript (c) HTML
  13. 13.✍️ What is the selector in this CSS rule?
    h2 {
      color: red;
      font-weight: bold;
      background-color: yellow;
      font-style: italic;
    }
    (a) bold (b) h2 (c) color (d) h1
  14. 14.True or false: padding is space inside the border. (a) False (b) True
  15. 15.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 330px;
      justify-content: space-between;
    }
    Inside are 4 boxes, each 60px wide (no margins).
  16. 16.🖌️ Where does the text sit on its line?
    h2 {
      text-align: left;
      background-color: black;
      font-size: 36px;
      color: orange;
    }
    (a) on the left (b) on the right (c) in the middle
  17. 17.🎯 What kind of selector is #top? (a) an id selector (b) an element selector (c) a class selector
  18. 18.Which of these does JavaScript do? (a) adds space around boxes (b) changes the page live (c) rounds box corners (d) sets colours and fonts
  19. 19.🌈 In #rrggbb, which colour do the last two digits give? (a) blue (b) white (c) red (d) green
  20. 20.True or false: CSS rounds box corners. (a) False (b) True
  21. 21.🎯 Which CSS selector matches this element?
    <span class="note" id="main">Hello</span>
    (a) #logo (b) .main (c) .note (d) .big
  22. 22.📱 The screen is 700px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 16px;
      }
    }
    (a) Yes (b) No
  23. 23.✍️ What is the selector in this CSS rule?
    h2 {
      padding: 8px;
      font-weight: bold;
      text-align: center;
      width: 300px;
    }
    (a) h2 (b) padding (c) bold (d) h1
  24. 24.🧩 Which language gives the page structure? (a) CSS (b) HTML (c) JavaScript
  25. 25.🔍 Which is the odd one out? (a) rounds box corners (b) checks a quiz answer (c) shows a pop-up message (d) reacts to a button click
  26. 26.True or false: margin is space outside the border. (a) False (b) True
  27. 27.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 6px;
      }
    }
  28. 28.🌈 In #2a0000 the red part is the hex number 2a. What is it as a normal number?
  29. 29.📱 The screen is 540px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 24px;
      }
    }
    (a) No (b) Yes
  30. 30.📱 What does a media query check? (a) the time of day (b) the page title (c) the screen width (d) the battery level
  31. 31.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 200px;
      padding: 30px;
      border: 5px solid black;
      margin: 5px;
    }
  32. 32.⚖️ What colour is the text of this element?
    <h2 class="big" id="main">Hi</h2>
    CSS:
    #main { color: black; }
    .big { color: purple; }
    h2 { color: orange; }
    (a) orange (b) green (c) purple (d) black
  33. 33.✍️ What is the selector in this CSS rule?
    .box {
      font-style: italic;
      background-color: yellow;
    }
    (a) font-style (b) .box (c) yellow (d) h2
  34. 34.💪 Which flexbox property turns on flexbox? (a) justify-content (b) gap (c) flex-direction (d) display: flex
  35. 35.⚖️ What colour is the text of this element?
    <p class="box" id="hero">Hi</p>
    CSS:
    #hero { color: purple; }
    p { color: white; }
    (a) blue (b) white (c) purple (d) black
  36. 36.Which of these does JavaScript do? (a) makes a link (b) rounds box corners (c) reacts to a button click (d) sets colours and fonts
  37. 37.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) exactly 100px (c) 800px or wider (d) turned off
  38. 38.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 180px;
      justify-content: space-between;
    }
    Inside are 2 boxes, each 60px wide (no margins).
  39. 39.🎯 Can many elements share the same class? (a) No (b) Yes
  40. 40.🧩 Which language shows a pop-up message? (a) CSS (b) HTML (c) JavaScript

Answer key

  1. False
  2. red
  3. 8px
  4. fits every screen
  5. 152
  6. 600px or narrower
  7. sets colours and fonts
  8. an id selector
  9. the later one
  10. False
  11. yellow
  12. JavaScript
  13. h2
  14. True
  15. 30
  16. on the left
  17. an id selector
  18. changes the page live
  19. blue
  20. True
  21. .note
  22. Yes
  23. h2
  24. HTML
  25. rounds box corners
  26. True
  27. 12
  28. 42
  29. Yes
  30. the screen width
  31. 280
  32. black
  33. .box
  34. display: flex
  35. purple
  36. reacts to a button click
  37. 800px or wider
  38. 60
  39. Yes
  40. JavaScript

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