← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 589 · 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 the box model, which part is space inside the border? (a) padding (b) border (c) content (d) margin
  2. 2.⚖️ What colour is the text of this element?
    <p class="big" id="logo">Hi</p>
    CSS:
    #logo { color: black; }
    p { color: blue; }
    (a) blue (b) black (c) green (d) white
  3. 3.✍️ What value is given to font-size in this rule?
    h1 {
      font-size: 20px;
      font-style: italic;
    }
    (a) center (b) 20px (c) font-size (d) yellow
  4. 4.What does font-family do? (a) makes letters bigger (b) centres a heading (c) picks the font style (d) makes the text bold
  5. 5.What does justify-content: flex-end do? (a) equal gaps, none at ends (b) puts boxes in the middle (c) packs boxes at the end (d) packs boxes at the start
  6. 6.⚖️ What colour is the text of this element?
    <h1 class="note" id="hero">Hi</h1>
    CSS:
    .note { color: green; }
    h1 { color: red; }
    #hero { color: yellow; }
    (a) green (b) white (c) yellow (d) red
  7. 7.📦 In the box model, which part is the text or picture? (a) border (b) margin (c) content (d) padding
  8. 8.🖌️ How big is the text, in px?
    p {
      text-align: center;
      background-color: orange;
      font-size: 40px;
      color: black;
    }
  9. 9.🎯 Which CSS selector matches this element?
    <li class="note" id="hero">Hello</li>
    (a) .big (b) #hero (c) div (d) #note
  10. 10.🎨 Which tag connects an outside CSS file? (a) <css> (b) <a> (c) <img> (d) <link>
  11. 11.⚖️ What colour is the text of this element?
    <h2 class="star" id="logo">Hi</h2>
    CSS:
    h2 { color: blue; }
    #logo { color: orange; }
    .star { color: black; }
    (a) orange (b) purple (c) blue (d) black
  12. 12.✍️ How many declarations (property: value pairs) are in this rule?
    li {
      text-align: center;
      width: 300px;
      font-size: 20px;
      border: 2px solid;
    }
  13. 13.What does justify-content: flex-start do? (a) packs boxes at the end (b) packs boxes at the start (c) equal gaps, none at ends (d) puts boxes in the middle
  14. 14.🌈 Which hex code is yellow? (a) #ffff00 (b) #000000 (c) #0000ff (d) #ff00ff
  15. 15.✍️ CSS declarations go inside which brackets? (a) ( ) (b) [ ] (c) < > (d) { }
  16. 16.True or false: padding is space inside the border. (a) True (b) False
  17. 17.True or false: margin is space outside the border. (a) False (b) True
  18. 18.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 100px;
      padding: 20px;
      border: 1px solid black;
      margin: 0px;
    }
  19. 19.💪 Which justify-content value packs boxes at the start? (a) space-between (b) center (c) flex-end (d) flex-start
  20. 20.📱 What does a media query check? (a) the screen width (b) the time of day (c) the battery level (d) the page title
  21. 21.📱 The screen is 700px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 22px;
      }
    }
    (a) Yes (b) No
  22. 22.✍️ Which property is set to 8px in this rule?
    .note {
      width: 300px;
      font-size: 20px;
      background-color: yellow;
      padding: 8px;
    }
    (a) border (b) padding (c) font-weight (d) 8px
  23. 23.🎯 Which CSS selector matches this element?
    <p class="box" id="hero">Hello</p>
    (a) h1 (b) .star (c) .box (d) #top
  24. 24.📱 min-width: 800px applies when the screen is ___. (a) 800px or wider (b) turned off (c) exactly 100px (d) 800px or narrower
  25. 25.✍️ What value is given to color in this rule?
    p {
      font-weight: bold;
      padding: 8px;
      color: red;
    }
    (a) 20px (b) center (c) color (d) red
  26. 26.True or false: img is an element selector. (a) False (b) True
  27. 27.🔍 Which is the odd one out? (a) sets colours and fonts (b) changes the text size (c) counts down a timer (d) adds space around boxes
  28. 28.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 28px;
      }
    }
  29. 29.🖌️ Which CSS property sets the letter colour? (a) color (b) font-size (c) text-align (d) font-weight
  30. 30.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 190px;
      padding: 5px;
      border: 1px solid black;
      margin: 0px;
    }
  31. 31.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 190px;
      padding: 20px;
      border: 1px solid black;
      margin: 20px;
    }
  32. 32.💪 Which flexbox property turns on flexbox? (a) flex-direction (b) gap (c) display: flex (d) justify-content
  33. 33.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 340px;
      justify-content: space-between;
    }
    Inside are 3 boxes, each 80px wide (no margins).
  34. 34.✍️ How many declarations (property: value pairs) are in this rule?
    li {
      padding: 8px;
    }
  35. 35.🎯 Which CSS selector matches this element?
    <p class="box" id="end">Hello</p>
    (a) #box (b) .box (c) #hero (d) .end
  36. 36.What does justify-content: space-between do? (a) equal gaps, none at ends (b) packs boxes at the end (c) puts boxes in the middle (d) packs boxes at the start
  37. 37.💪 Which justify-content value puts boxes in the middle? (a) flex-end (b) space-between (c) center (d) flex-start
  38. 38.⚖️ What colour is the text of this element?
    <p class="box" id="main">Hi</p>
    CSS:
    .box { color: orange; }
    #main { color: purple; }
    (a) black (b) purple (c) orange (d) white
  39. 39.🖌️ How big is the text, in px?
    h1 {
      font-size: 16px;
      background-color: white;
      text-align: center;
      color: orange;
    }
  40. 40.✍️ Which sign ends each CSS declaration? (a) , (b) ; (c) : (d) .

Answer key

  1. padding
  2. black
  3. 20px
  4. picks the font style
  5. packs boxes at the end
  6. yellow
  7. content
  8. 40
  9. #hero
  10. <link>
  11. orange
  12. 4
  13. packs boxes at the start
  14. #ffff00
  15. { }
  16. True
  17. True
  18. 142
  19. flex-start
  20. the screen width
  21. Yes
  22. padding
  23. .box
  24. 800px or wider
  25. red
  26. True
  27. counts down a timer
  28. 28
  29. color
  30. 202
  31. 272
  32. display: flex
  33. 50
  34. 1
  35. .box
  36. equal gaps, none at ends
  37. center
  38. purple
  39. 16
  40. ;

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