← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 235 · 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.📱 The screen is 700px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 22px;
      }
    }
    (a) No (b) Yes
  2. 2.⚖️ What colour is the text of this element?
    <h2 class="menu" id="logo">Hi</h2>
    CSS:
    #logo { color: green; }
    .menu { color: orange; }
    h2 { color: red; }
    (a) black (b) green (c) red (d) orange
  3. 3.⚖️ What colour is the text of this element?
    <h2 class="box" id="top">Hi</h2>
    CSS:
    h2 { color: red; }
    h2 { color: black; }
    (a) green (b) red (c) purple (d) black
  4. 4.True or false: .menu is an id selector. (a) False (b) True
  5. 5.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      background-color: yellow;
      font-style: italic;
    }
  6. 6.🔍 Which is the odd one out? (a) shows a pop-up message (b) counts down a timer (c) checks a quiz answer (d) makes a form box
  7. 7.📱 Which tag helps phones show a page at the right size? (a) the title tag (b) the viewport meta tag (c) the br tag (d) the hr tag
  8. 8.✍️ What value is given to border in this rule?
    h2 {
      border: 2px solid;
      text-align: center;
      padding: 8px;
    }
    (a) border (b) 300px (c) italic (d) 2px solid
  9. 9.🎯 Can many elements share the same class? (a) Yes (b) No
  10. 10.⚖️ What colour is the text of this element?
    <h1 class="note" id="logo">Hi</h1>
    CSS:
    h1 { color: purple; }
    .note { color: red; }
    #logo { color: green; }
    (a) red (b) purple (c) yellow (d) green
  11. 11.🌈 Which colour is #ffff00? (a) yellow (b) blue (c) bright green (d) red
  12. 12.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
  13. 13.⚖️ Which selector is the strongest? (a) an id selector (b) a class selector (c) an element selector
  14. 14.True or false: JavaScript lays out the page. (a) True (b) False
  15. 15.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 330px;
      justify-content: flex-end;
    }
    Inside are 3 boxes, each 100px wide (no margins).
  16. 16.✍️ How does a CSS comment start? (a) /* (b) <!-- (c) # (d) //
  17. 17.🎯 Which CSS selector matches this element?
    <div class="box" id="top">Hello</div>
    (a) .box (b) #box (c) #intro (d) .star
  18. 18.What does color do? (a) colours behind the text (b) makes the text bold (c) sets the letter colour (d) centres a heading
  19. 19.True or false: li is an element selector. (a) True (b) False
  20. 20.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) blue (c) red (d) black
  21. 21.📦 In the box model, which part is the line round the box? (a) border (b) padding (c) margin (d) content
  22. 22.⚖️ What colour is the text of this element?
    <h1 class="star" id="top">Hi</h1>
    CSS:
    #top { color: red; }
    #top { color: blue; }
    (a) orange (b) green (c) blue (d) red
  23. 23.🖌️ What colour is behind the letters?
    h1 {
      text-align: center;
      font-size: 32px;
      color: black;
      background-color: green;
    }
    (a) blue (b) green (c) black
  24. 24.🖌️ Which CSS property colours behind the text? (a) font-size (b) font-family (c) font-weight (d) background-color
  25. 25.📱 The screen is 700px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 20px;
      }
    }
    (a) No (b) Yes
  26. 26.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 14px;
      }
    }
  27. 27.📱 max-width: 600px applies when the screen is ___. (a) 600px or narrower (b) 600px or wider (c) exactly 1000px (d) turned off
  28. 28.🖌️ Which CSS property makes letters bigger? (a) font-size (b) text-align (c) font-weight (d) background-color
  29. 29.🎯 What kind of selector is #main? (a) a class selector (b) an element selector (c) an id selector
  30. 30.🧩 Which language reacts to a button click? (a) HTML (b) JavaScript (c) CSS
  31. 31.🎯 What kind of selector is #top? (a) an id selector (b) an element selector (c) a class selector
  32. 32.🎯 Which CSS selector matches this element?
    <span class="box" id="main">Hello</span>
    (a) .star (b) #box (c) .box (d) #logo
  33. 33.True or false: the border is a solid or dotted edge. (a) False (b) True
  34. 34.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) turned off (c) 800px or wider (d) exactly 100px
  35. 35.✍️ Which property is set to 8px in this rule?
    h2 {
      font-size: 20px;
      color: red;
      margin: 10px;
      padding: 8px;
    }
    (a) 8px (b) font-weight (c) padding (d) border
  36. 36.🌈 Which hex code is white? (a) #00ffff (b) #ffff00 (c) #ffffff (d) #0000ff
  37. 37.🎯 What kind of selector is .card? (a) an id selector (b) an element selector (c) a class selector
  38. 38.✍️ Which sign ends each CSS declaration? (a) : (b) ; (c) , (d) .
  39. 39.✍️ What value is given to font-size in this rule?
    li {
      font-size: 20px;
      margin: 10px;
      color: red;
    }
    (a) center (b) 20px (c) font-size (d) yellow
  40. 40.💪 Which flexbox property turns on flexbox? (a) gap (b) align-items (c) justify-content (d) display: flex

Answer key

  1. No
  2. green
  3. black
  4. False
  5. 2
  6. makes a form box
  7. the viewport meta tag
  8. 2px solid
  9. Yes
  10. green
  11. yellow
  12. an element selector
  13. an id selector
  14. False
  15. 30
  16. /*
  17. .box
  18. sets the letter colour
  19. True
  20. red
  21. border
  22. blue
  23. green
  24. background-color
  25. No
  26. 12
  27. 600px or narrower
  28. font-size
  29. an id selector
  30. JavaScript
  31. an id selector
  32. .box
  33. True
  34. 800px or wider
  35. padding
  36. #ffffff
  37. a class selector
  38. ;
  39. 20px
  40. display: flex

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