← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 827 · 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 value is given to margin in this rule?
    p {
      margin: 10px;
      color: red;
    }
    (a) 8px (b) margin (c) bold (d) 10px
  2. 2.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 22px;
      }
    }
  3. 3.True or false: JavaScript adds space around boxes. (a) True (b) False
  4. 4.🧩 Which language checks a quiz answer? (a) JavaScript (b) HTML (c) CSS
  5. 5.🎯 Which CSS selector matches this element?
    <h2 class="big" id="logo">Hello</h2>
    (a) li (b) .red (c) #end (d) #logo
  6. 6.💪 Which justify-content value equal gaps, none at ends? (a) center (b) space-between (c) flex-end (d) flex-start
  7. 7.What does justify-content: flex-start 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
  8. 8.🎯 Which CSS selector matches this element?
    <h1 class="box" id="top">Hello</h1>
    (a) .box (b) #box (c) .top (d) .star
  9. 9.✍️ Which sign goes between a property and its value? (a) = (b) : (c) - (d) ;
  10. 10.🎯 Which element does the selector span style? (a) <h2 id="end"> (b) <p> (c) <h1 class="menu"> (d) <span class="menu">
  11. 11.What does color do? (a) makes the text bold (b) sets the letter colour (c) colours behind the text (d) picks the font style
  12. 12.🖌️ What colour are the letters?
    p {
      text-align: center;
      font-size: 20px;
      color: blue;
      background-color: white;
    }
    (a) blue (b) white (c) green
  13. 13.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 3 (b) 4 (c) 2 (d) 6
  14. 14.🖌️ How big is the text, in px?
    p {
      color: blue;
      text-align: left;
      background-color: green;
      font-size: 28px;
    }
  15. 15.🖌️ How big is the text, in px?
    h2 {
      text-align: right;
      background-color: yellow;
      font-size: 16px;
      color: purple;
    }
  16. 16.🎯 What kind of selector is .big? (a) an id selector (b) an element selector (c) a class selector
  17. 17.🎯 Can many elements share the same class? (a) No (b) Yes
  18. 18.🖌️ What colour is behind the letters?
    h2 {
      font-size: 16px;
      background-color: blue;
      color: black;
      text-align: left;
    }
    (a) black (b) blue (c) white
  19. 19.🌈 Which colour is #00ff00? (a) red (b) bright green (c) yellow (d) black
  20. 20.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 270px;
      padding: 25px;
      border: 1px solid black;
      margin: 20px;
    }
  21. 21.Which of these does HTML do? (a) makes a form box (b) counts down a timer (c) sets colours and fonts (d) checks a quiz answer
  22. 22.What does justify-content: space-between 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
  23. 23.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 22px;
      }
    }
  24. 24.What does background-color do? (a) sets the letter colour (b) makes the text bold (c) colours behind the text (d) makes letters bigger
  25. 25.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 30px;
      }
    }
    (a) Yes (b) No
  26. 26.True or false: JavaScript gives the page structure. (a) True (b) False
  27. 27.🌈 In #00a600 the green part is the hex number a6. What is it as a normal number?
  28. 28.⚖️ What colour is the text of this element?
    <p class="box" id="intro">Hi</p>
    CSS:
    p { color: orange; }
    p { color: purple; }
    (a) white (b) purple (c) orange (d) blue
  29. 29.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 140px;
      padding: 10px;
      border: 3px solid black;
      margin: 10px;
    }
  30. 30.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 22px;
      }
    }
  31. 31.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 260px;
      justify-content: space-between;
    }
    Inside are 3 boxes, each 60px wide (no margins).
  32. 32.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      text-align: center;
      color: red;
      font-style: italic;
      font-size: 20px;
    }
  33. 33.🧩 Which language makes a link? (a) HTML (b) CSS (c) JavaScript
  34. 34.🖌️ What colour is behind the letters?
    li {
      text-align: right;
      font-size: 20px;
      background-color: yellow;
      color: green;
    }
    (a) green (b) yellow (c) orange
  35. 35.🎯 Which CSS selector matches this element?
    <h1 class="note" id="top">Hello</h1>
    (a) #note (b) #intro (c) h1 (d) .big
  36. 36.🎯 Which CSS selector matches this element?
    <h2 class="star" id="main">Hello</h2>
    (a) li (b) .main (c) h2 (d) #star
  37. 37.What does justify-content: center do? (a) packs boxes at the start (b) packs boxes at the end (c) equal gaps, none at ends (d) puts boxes in the middle
  38. 38.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 220px;
      justify-content: flex-start;
    }
    Inside are 4 boxes, each 50px wide (no margins).
  39. 39.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 210px;
      justify-content: space-between;
    }
    Inside are 2 boxes, each 100px wide (no margins).
  40. 40.✍️ Which property is set to bold in this rule?
    #top {
      font-style: italic;
      background-color: yellow;
      font-weight: bold;
      width: 300px;
    }
    (a) font-weight (b) border (c) bold (d) width

Answer key

  1. 10px
  2. 22
  3. False
  4. JavaScript
  5. #logo
  6. space-between
  7. packs boxes at the start
  8. .box
  9. :
  10. <span class="menu">
  11. sets the letter colour
  12. blue
  13. 3
  14. 28
  15. 16
  16. a class selector
  17. Yes
  18. blue
  19. bright green
  20. 362
  21. makes a form box
  22. equal gaps, none at ends
  23. 22
  24. colours behind the text
  25. No
  26. False
  27. 166
  28. purple
  29. 186
  30. 16
  31. 40
  32. 4
  33. HTML
  34. yellow
  35. h1
  36. h2
  37. puts boxes in the middle
  38. 20
  39. 10
  40. font-weight

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