← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 304 · 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.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) neither (c) the first one (d) the later one
  2. 2.📦 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: 25px;
      border: 3px solid black;
      margin: 20px;
    }
  3. 3.🌈 Which colour is #00ffff? (a) cyan (b) red (c) black (d) magenta
  4. 4.What does font-size do? (a) makes the text bold (b) makes letters bigger (c) picks the font style (d) sets the letter colour
  5. 5.🌈 In #rrggbb, which colour do the last two digits give? (a) white (b) red (c) blue (d) green
  6. 6.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 28px;
      }
    }
  7. 7.✍️ In color: blue; which part is the value? (a) ; (b) blue (c) color (d) :
  8. 8.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
  9. 9.True or false: li is a class selector. (a) False (b) True
  10. 10.📱 The screen is 540px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 10px;
      }
    }
    (a) No (b) Yes
  11. 11.🎯 Which element does the selector h2 style? (a) <li> (b) <span id="logo"> (c) <div class="menu"> (d) <h2 class="menu">
  12. 12.✍️ CSS declarations go inside which brackets? (a) ( ) (b) [ ] (c) { } (d) < >
  13. 13.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 4 (b) 3 (c) 6 (d) 2
  14. 14.🎯 What kind of selector is .star? (a) an element selector (b) a class selector (c) an id selector
  15. 15.🌈 In #7b0000 the red part is the hex number 7b. What is it as a normal number?
  16. 16.✍️ What value is given to font-weight in this rule?
    .note {
      font-weight: bold;
      border: 2px solid;
    }
    (a) bold (b) font-weight (c) 2px solid (d) 300px
  17. 17.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 18px;
      }
    }
  18. 18.📱 The screen is 700px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 24px;
      }
    }
    (a) No (b) Yes
  19. 19.What does text-align do? (a) makes letters bigger (b) centres a heading (c) sets the letter colour (d) colours behind the text
  20. 20.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 190px;
      justify-content: flex-end;
    }
    Inside are 3 boxes, each 50px wide (no margins).
  21. 21.⚖️ What colour is the text of this element?
    <p class="big" id="main">Hi</p>
    CSS:
    #main { color: red; }
    #main { color: yellow; }
    (a) red (b) white (c) yellow (d) green
  22. 22.🖌️ Where does the text sit on its line?
    h1 {
      background-color: blue;
      font-size: 12px;
      text-align: right;
      color: black;
    }
    (a) on the left (b) on the right (c) in the middle
  23. 23.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 180px;
      padding: 10px;
      border: 2px solid black;
      margin: 10px;
    }
  24. 24.🌈 Which hex code is cyan? (a) #0000ff (b) #ffffff (c) #00ffff (d) #00ff00
  25. 25.🖌️ Which CSS property colours behind the text? (a) font-size (b) text-align (c) color (d) background-color
  26. 26.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 410px;
      justify-content: space-between;
    }
    Inside are 4 boxes, each 50px wide (no margins).
  27. 27.True or false: CSS rounds box corners. (a) False (b) True
  28. 28.✍️ Which property is set to 8px in this rule?
    #top {
      padding: 8px;
      border: 2px solid;
    }
    (a) 8px (b) padding (c) border (d) font-weight
  29. 29.💪 Which flexbox property sets space between boxes? (a) gap (b) display: flex (c) flex-direction (d) justify-content
  30. 30.True or false: h1 is an id selector. (a) True (b) False
  31. 31.🎯 Which CSS selector matches this element?
    <span class="note" id="main">Hello</span>
    (a) p (b) .note (c) .main (d) #logo
  32. 32.🔍 Which is the odd one out? (a) gives the page structure (b) makes headings and lists (c) checks a quiz answer (d) makes a link
  33. 33.📱 Which tag helps phones show a page at the right size? (a) the viewport meta tag (b) the title tag (c) the hr tag (d) the br tag
  34. 34.✍️ Which property is set to center in this rule?
    body {
      text-align: center;
      color: red;
      font-size: 20px;
    }
    (a) margin (b) center (c) background-color (d) text-align
  35. 35.✍️ In color: blue; which part is the property? (a) ; (b) : (c) color (d) blue
  36. 36.⚖️ What colour is the text of this element?
    <h1 class="red" id="logo">Hi</h1>
    CSS:
    h1 { color: orange; }
    h1 { color: black; }
    (a) black (b) orange (c) green (d) purple
  37. 37.What does justify-content: flex-end do? (a) packs boxes at the start (b) packs boxes at the end (c) puts boxes in the middle (d) equal gaps, none at ends
  38. 38.🖌️ Where does the text sit on its line?
    h2 {
      font-size: 40px;
      text-align: left;
      background-color: red;
      color: orange;
    }
    (a) in the middle (b) on the right (c) on the left
  39. 39.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 22px;
      }
    }
  40. 40.🔍 Which is the odd one out? (a) counts down a timer (b) changes the text size (c) adds space around boxes (d) rounds box corners

Answer key

  1. the later one
  2. 126
  3. cyan
  4. makes letters bigger
  5. blue
  6. 24
  7. blue
  8. an element selector
  9. False
  10. Yes
  11. <h2 class="menu">
  12. { }
  13. 3
  14. a class selector
  15. 123
  16. bold
  17. 18
  18. Yes
  19. centres a heading
  20. 40
  21. yellow
  22. on the right
  23. 224
  24. #00ffff
  25. background-color
  26. 70
  27. True
  28. padding
  29. gap
  30. False
  31. .note
  32. checks a quiz answer
  33. the viewport meta tag
  34. text-align
  35. color
  36. black
  37. packs boxes at the end
  38. on the left
  39. 24
  40. counts down a timer

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