← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 548 · 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 375px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 10px;
      }
    }
  2. 2.🎨 Which tag connects an outside CSS file? (a) <a> (b) <css> (c) <img> (d) <link>
  3. 3.✍️ Which property is set to 300px in this rule?
    .note {
      background-color: yellow;
      font-size: 20px;
      width: 300px;
    }
    (a) font-style (b) width (c) color (d) 300px
  4. 4.✍️ What value is given to padding in this rule?
    #top {
      padding: 8px;
      background-color: yellow;
    }
    (a) 2px solid (b) padding (c) 8px (d) bold
  5. 5.✍️ What value is given to border in this rule?
    h2 {
      margin: 10px;
      border: 2px solid;
    }
    (a) 300px (b) border (c) 2px solid (d) italic
  6. 6.✍️ What value is given to font-style in this rule?
    li {
      font-size: 20px;
      text-align: center;
      font-style: italic;
      background-color: yellow;
    }
    (a) 20px (b) red (c) font-style (d) italic
  7. 7.🌈 Which colour is rgb(255, 0, 255)? (a) magenta (b) yellow (c) red (d) cyan
  8. 8.🌈 Which colour is #000000? (a) black (b) white (c) magenta (d) bright green
  9. 9.⚖️ What colour is the text of this element?
    <h1 class="star" id="end">Hi</h1>
    CSS:
    #end { color: purple; }
    #end { color: white; }
    (a) purple (b) red (c) white (d) black
  10. 10.What does justify-content: space-between do? (a) packs boxes at the end (b) packs boxes at the start (c) puts boxes in the middle (d) equal gaps, none at ends
  11. 11.🎯 Which CSS selector matches this element?
    <p class="menu" id="main">Hello</p>
    (a) #logo (b) .menu (c) #menu (d) .note
  12. 12.True or false: JavaScript counts down a timer. (a) False (b) True
  13. 13.Which of these is margin? (a) space outside the border (b) a solid or dotted edge (c) space inside the border (d) the line round the box
  14. 14.True or false: .star is a class selector. (a) False (b) True
  15. 15.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 18px;
      }
    }
    (a) Yes (b) No
  16. 16.🌈 Which colour is rgb(255, 255, 0)? (a) red (b) magenta (c) yellow (d) cyan
  17. 17.✍️ What value is given to font-style in this rule?
    h1 {
      width: 300px;
      color: red;
      font-style: italic;
    }
    (a) 20px (b) italic (c) font-style (d) red
  18. 18.✍️ What value is given to font-size in this rule?
    .box {
      text-align: center;
      font-size: 20px;
    }
    (a) yellow (b) font-size (c) 20px (d) center
  19. 19.⚖️ What colour is the text of this element?
    <h1 class="box" id="main">Hi</h1>
    CSS:
    .box { color: white; }
    #main { color: blue; }
    (a) white (b) green (c) red (d) blue
  20. 20.🎯 Which element does the selector h1 style? (a) <div id="top"> (b) <li class="red"> (c) <h1 class="red"> (d) <h2>
  21. 21.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 110px;
      justify-content: flex-end;
    }
    Inside are 2 boxes, each 50px wide (no margins).
  22. 22.🎨 Which attribute adds CSS inside one tag? (a) src (b) style (c) href (d) alt
  23. 23.✍️ What value is given to border in this rule?
    .box {
      border: 2px solid;
      background-color: yellow;
      font-size: 20px;
    }
    (a) border (b) italic (c) 2px solid (d) 300px
  24. 24.🎯 Which CSS selector matches this element?
    <div class="note" id="end">Hello</div>
    (a) .end (b) #hero (c) div (d) span
  25. 25.🖌️ Which CSS property makes the text bold? (a) font-size (b) font-weight (c) background-color (d) color
  26. 26.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 260px;
      justify-content: center;
    }
    Inside are 4 boxes, each 50px wide (no margins).
  27. 27.🎯 Which element does the selector .big style? (a) <li class="big"> (b) <div class="box"> (c) <li class="red"> (d) <li id="big">
  28. 28.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      border: 2px solid;
    }
  29. 29.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 100px;
      justify-content: center;
    }
    Inside are 2 boxes, each 40px wide (no margins).
  30. 30.✍️ Which sign goes between a property and its value? (a) - (b) ; (c) : (d) =
  31. 31.🌈 Which colour is #ffffff? (a) yellow (b) white (c) bright green (d) black
  32. 32.🌈 In #rrggbb, which colour do the last two digits give? (a) white (b) green (c) blue (d) red
  33. 33.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 20px;
      }
    }
    (a) Yes (b) No
  34. 34.🎯 Which sign starts an id selector? (a) @ (b) & (c) # (d) .
  35. 35.🖌️ Where does the text sit on its line?
    li {
      color: blue;
      font-size: 32px;
      background-color: purple;
      text-align: left;
    }
    (a) on the right (b) on the left (c) in the middle
  36. 36.True or false: HTML sets colours and fonts. (a) False (b) True
  37. 37.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 340px;
      justify-content: center;
    }
    Inside are 4 boxes, each 50px wide (no margins).
  38. 38.⚖️ What colour is the text of this element?
    <p class="box" id="end">Hi</p>
    CSS:
    .box { color: black; }
    p { color: purple; }
    (a) purple (b) white (c) blue (d) black
  39. 39.✍️ Which property is set to 2px solid in this rule?
    .box {
      border: 2px solid;
      font-size: 20px;
      font-style: italic;
    }
    (a) width (b) 2px solid (c) border (d) font-style
  40. 40.True or false: padding is space inside the border. (a) False (b) True

Answer key

  1. 10
  2. <link>
  3. width
  4. 8px
  5. 2px solid
  6. italic
  7. magenta
  8. black
  9. white
  10. equal gaps, none at ends
  11. .menu
  12. True
  13. space outside the border
  14. True
  15. Yes
  16. yellow
  17. italic
  18. 20px
  19. blue
  20. <h1 class="red">
  21. 10
  22. style
  23. 2px solid
  24. div
  25. font-weight
  26. 30
  27. <li class="big">
  28. 1
  29. 10
  30. :
  31. white
  32. blue
  33. Yes
  34. #
  35. on the left
  36. False
  37. 70
  38. black
  39. border
  40. True

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