← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 64 · 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 kind of selector is #top? (a) an id selector (b) an element selector (c) a class selector
  2. 2.True or false: #end is an id selector. (a) True (b) False
  3. 3.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 80px;
      padding: 15px;
      border: 3px solid black;
      margin: 20px;
    }
  4. 4.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 70px;
      padding: 5px;
      border: 3px solid black;
      margin: 5px;
    }
  5. 5.⚖️ What colour is the text of this element?
    <p class="menu" id="intro">Hi</p>
    CSS:
    #intro { color: black; }
    #intro { color: white; }
    (a) white (b) blue (c) black (d) orange
  6. 6.✍️ Which sign ends each CSS declaration? (a) . (b) ; (c) : (d) ,
  7. 7.📱 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
  8. 8.🌈 Which colour is #0000ff? (a) black (b) red (c) magenta (d) blue
  9. 9.⚖️ What colour is the text of this element?
    <h2 class="red" id="end">Hi</h2>
    CSS:
    .red { color: black; }
    h2 { color: orange; }
    (a) red (b) white (c) orange (d) black
  10. 10.🖌️ What colour are the letters?
    h1 {
      font-size: 12px;
      background-color: red;
      color: black;
      text-align: right;
    }
    (a) black (b) orange (c) red
  11. 11.🎯 Which CSS selector matches this element?
    <p class="big" id="hero">Hello</p>
    (a) #big (b) p (c) h1 (d) .hero
  12. 12.✍️ What value is given to padding in this rule?
    body {
      width: 300px;
      padding: 8px;
      font-weight: bold;
      font-style: italic;
    }
    (a) 2px solid (b) bold (c) 8px (d) padding
  13. 13.📱 What does a media query check? (a) the battery level (b) the time of day (c) the page title (d) the screen width
  14. 14.🎯 Which CSS selector matches this element?
    <p class="box" id="logo">Hello</p>
    (a) .logo (b) .box (c) .star (d) #end
  15. 15.🎯 Which CSS selector matches this element?
    <li class="big" id="intro">Hello</li>
    (a) #main (b) li (c) #big (d) div
  16. 16.🎯 Which CSS selector matches this element?
    <h2 class="note" id="hero">Hello</h2>
    (a) .hero (b) .note (c) .big (d) #note
  17. 17.True or false: li is a class selector. (a) False (b) True
  18. 18.🎯 What kind of selector is body? (a) an id selector (b) an element selector (c) a class selector
  19. 19.True or false: .card is an element selector. (a) True (b) False
  20. 20.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 340px;
      justify-content: flex-start;
    }
    Inside are 3 boxes, each 100px wide (no margins).
  21. 21.✍️ What value is given to font-size in this rule?
    .note {
      width: 300px;
      font-size: 20px;
    }
    (a) center (b) yellow (c) font-size (d) 20px
  22. 22.⚖️ What colour is the text of this element?
    <p class="red" id="hero">Hi</p>
    CSS:
    p { color: purple; }
    .red { color: orange; }
    (a) yellow (b) orange (c) purple (d) white
  23. 23.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 250px;
      justify-content: center;
    }
    Inside are 3 boxes, each 50px wide (no margins).
  24. 24.🎯 Which CSS selector matches this element?
    <h1 class="big" id="hero">Hello</h1>
    (a) #top (b) h1 (c) .hero (d) #big
  25. 25.🖌️ What colour is behind the letters?
    h1 {
      background-color: black;
      text-align: center;
      color: red;
      font-size: 24px;
    }
    (a) red (b) black (c) white
  26. 26.🎯 Which CSS selector matches this element?
    <p class="star" id="intro">Hello</p>
    (a) .intro (b) #main (c) .menu (d) #intro
  27. 27.✍️ What value is given to border in this rule?
    #top {
      border: 2px solid;
      font-weight: bold;
    }
    (a) 300px (b) italic (c) 2px solid (d) border
  28. 28.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 150px;
      justify-content: flex-end;
    }
    Inside are 2 boxes, each 40px wide (no margins).
  29. 29.⚖️ What colour is the text of this element?
    <p class="box" id="main">Hi</p>
    CSS:
    .box { color: orange; }
    p { color: yellow; }
    #main { color: black; }
    (a) yellow (b) green (c) black (d) orange
  30. 30.🎯 What kind of selector is .big? (a) an element selector (b) an id selector (c) a class selector
  31. 31.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 20px;
      }
    }
  32. 32.🧩 Which language counts down a timer? (a) CSS (b) JavaScript (c) HTML
  33. 33.⚖️ What colour is the text of this element?
    <h1 class="red" id="hero">Hi</h1>
    CSS:
    #hero { color: white; }
    h1 { color: red; }
    (a) white (b) red (c) blue (d) orange
  34. 34.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 10px;
      }
    }
  35. 35.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 230px;
      padding: 15px;
      border: 1px solid black;
      margin: 0px;
    }
  36. 36.Which of these does HTML do? (a) makes a link (b) reacts to a button click (c) rounds box corners (d) checks a quiz answer
  37. 37.✍️ CSS declarations go inside which brackets? (a) ( ) (b) < > (c) [ ] (d) { }
  38. 38.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 26px;
      }
    }
  39. 39.True or false: #hero is an id selector. (a) True (b) False
  40. 40.🎨 Which attribute adds CSS inside one tag? (a) href (b) alt (c) src (d) style

Answer key

  1. an id selector
  2. True
  3. 156
  4. 86
  5. white
  6. ;
  7. the viewport meta tag
  8. blue
  9. black
  10. black
  11. p
  12. 8px
  13. the screen width
  14. .box
  15. li
  16. .note
  17. False
  18. an element selector
  19. False
  20. 40
  21. 20px
  22. orange
  23. 50
  24. h1
  25. black
  26. #intro
  27. 2px solid
  28. 70
  29. black
  30. a class selector
  31. 24
  32. JavaScript
  33. white
  34. 16
  35. 262
  36. makes a link
  37. { }
  38. 26
  39. True
  40. style

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