← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 298 · 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.🌈 In #rrggbb, which colour do the last two digits give? (a) blue (b) white (c) green (d) red
  2. 2.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      background-color: yellow;
      color: red;
      text-align: center;
    }
  3. 3.What does font-size do? (a) centres a heading (b) sets the letter colour (c) picks the font style (d) makes letters bigger
  4. 4.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 32px;
      }
    }
  5. 5.✍️ Which property is set to 8px in this rule?
    li {
      text-align: center;
      padding: 8px;
      background-color: yellow;
    }
    (a) 8px (b) border (c) font-weight (d) padding
  6. 6.What does font-weight do? (a) centres a heading (b) makes the text bold (c) picks the font style (d) makes letters bigger
  7. 7.✍️ What is the selector in this CSS rule?
    #top {
      background-color: yellow;
      color: red;
      text-align: center;
    }
    (a) red (b) li (c) background-color (d) #top
  8. 8.📱 Responsive design means a page ___. (a) fits every screen (b) has no pictures (c) is only for laptops (d) never changes
  9. 9.True or false: #main is an id selector. (a) False (b) True
  10. 10.Which of these does JavaScript do? (a) rounds box corners (b) checks a quiz answer (c) makes headings and lists (d) sets colours and fonts
  11. 11.🎯 What kind of selector is img? (a) an element selector (b) a class selector (c) an id selector
  12. 12.🔍 Which is the odd one out? (a) adds space around boxes (b) lays out the page (c) changes the text size (d) makes headings and lists
  13. 13.🌈 Which colour is #ff00ff? (a) white (b) yellow (c) red (d) magenta
  14. 14.🖌️ What colour is behind the letters?
    p {
      text-align: left;
      background-color: black;
      font-size: 32px;
      color: blue;
    }
    (a) blue (b) green (c) black
  15. 15.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
  16. 16.What does justify-content: flex-start do? (a) packs boxes at the end (b) puts boxes in the middle (c) packs boxes at the start (d) equal gaps, none at ends
  17. 17.🌈 Which colour is #ff0000? (a) yellow (b) red (c) cyan (d) blue
  18. 18.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 290px;
      padding: 30px;
      border: 1px solid black;
      margin: 10px;
    }
  19. 19.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 360px;
      justify-content: center;
    }
    Inside are 4 boxes, each 50px wide (no margins).
  20. 20.⚖️ What colour is the text of this element?
    <h2 class="box" id="intro">Hi</h2>
    CSS:
    .box { color: blue; }
    #intro { color: black; }
    (a) black (b) red (c) blue (d) orange
  21. 21.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 32px;
      }
    }
  22. 22.🧩 Which language shows a pop-up message? (a) JavaScript (b) CSS (c) HTML
  23. 23.🎯 Which CSS selector matches this element?
    <p class="box" id="intro">Hello</p>
    (a) h1 (b) .intro (c) #main (d) .box
  24. 24.💪 Which flexbox property picks row or column? (a) flex-direction (b) align-items (c) justify-content (d) gap
  25. 25.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 90px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 40px wide (no margins).
  26. 26.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) 800px or wider (c) 800px or narrower (d) exactly 100px
  27. 27.🌈 Which colour of light is strongest in rgb(174, 97, 75)? (a) red (b) green (c) blue
  28. 28.True or false: JavaScript checks a quiz answer. (a) True (b) False
  29. 29.⚖️ What colour is the text of this element?
    <p class="big" id="end">Hi</p>
    CSS:
    p { color: orange; }
    p { color: red; }
    (a) orange (b) blue (c) white (d) red
  30. 30.🖌️ How big is the text, in px?
    h1 {
      font-size: 40px;
      text-align: left;
      color: red;
      background-color: white;
    }
  31. 31.💪 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).
  32. 32.📱 The screen is 540px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 18px;
      }
    }
    (a) Yes (b) No
  33. 33.True or false: CSS checks a quiz answer. (a) False (b) True
  34. 34.⚖️ What colour is the text of this element?
    <h2 class="note" id="logo">Hi</h2>
    CSS:
    #logo { color: purple; }
    #logo { color: white; }
    (a) green (b) purple (c) white (d) red
  35. 35.✍️ How does a CSS comment start? (a) <!-- (b) // (c) # (d) /*
  36. 36.📱 Which tag helps phones show a page at the right size? (a) the hr tag (b) the br tag (c) the title tag (d) the viewport meta tag
  37. 37.🌈 Which hex code is yellow? (a) #ffff00 (b) #ff00ff (c) #000000 (d) #0000ff
  38. 38.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 14px;
      }
    }
  39. 39.📱 The screen is 320px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 20px;
      }
    }
    (a) Yes (b) No
  40. 40.🎯 Which element does the selector .star style? (a) <span id="star"> (b) <span class="menu"> (c) <span class="star"> (d) <p class="note">

Answer key

  1. blue
  2. 3
  3. makes letters bigger
  4. 24
  5. padding
  6. makes the text bold
  7. #top
  8. fits every screen
  9. True
  10. checks a quiz answer
  11. an element selector
  12. makes headings and lists
  13. magenta
  14. black
  15. an element selector
  16. packs boxes at the start
  17. red
  18. 372
  19. 80
  20. black
  21. 32
  22. JavaScript
  23. .box
  24. flex-direction
  25. 10
  26. 800px or wider
  27. red
  28. True
  29. red
  30. 40
  31. 70
  32. No
  33. False
  34. white
  35. /*
  36. the viewport meta tag
  37. #ffff00
  38. 20
  39. No
  40. <span class="star">

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