← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 79 · 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.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      text-align: center;
      color: red;
      font-weight: bold;
      padding: 8px;
    }
  2. 2.True or false: the border is space inside the border. (a) True (b) False
  3. 3.🌈 Which colour is #00ffff? (a) yellow (b) white (c) cyan (d) red
  4. 4.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      text-align: center;
      font-size: 20px;
      color: red;
      font-style: italic;
    }
  5. 5.🌈 Which colour is rgb(0, 0, 0)? (a) red (b) black (c) magenta (d) cyan
  6. 6.🖌️ Which CSS property makes the text bold? (a) background-color (b) font-family (c) font-weight (d) font-size
  7. 7.✍️ In color: blue; which part is the property? (a) : (b) blue (c) ; (d) color
  8. 8.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 18px;
      }
    }
  9. 9.📱 What does a media query check? (a) the time of day (b) the screen width (c) the page title (d) the battery level
  10. 10.✍️ CSS declarations go inside which brackets? (a) ( ) (b) [ ] (c) { } (d) < >
  11. 11.⚖️ What colour is the text of this element?
    <h1 class="menu" id="top">Hi</h1>
    CSS:
    h1 { color: green; }
    #top { color: yellow; }
    .menu { color: red; }
    (a) green (b) red (c) yellow (d) blue
  12. 12.🎯 Which sign starts a class selector? (a) @ (b) # (c) & (d) .
  13. 13.🔍 Which is the odd one out? (a) gives the page structure (b) shows a pop-up message (c) makes headings and lists (d) makes a link
  14. 14.What does justify-content: center 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
  15. 15.✍️ What is the selector in this CSS rule?
    #top {
      width: 300px;
      font-size: 20px;
      font-weight: bold;
      text-align: center;
    }
    (a) 20px (b) li (c) #top (d) width
  16. 16.🎯 Which CSS selector matches this element?
    <h2 class="big" id="hero">Hello</h2>
    (a) #hero (b) .hero (c) #top (d) #big
  17. 17.🖌️ How big is the text, in px?
    h2 {
      text-align: left;
      background-color: purple;
      color: green;
      font-size: 28px;
    }
  18. 18.⚖️ What colour is the text of this element?
    <h1 class="menu" id="main">Hi</h1>
    CSS:
    h1 { color: black; }
    h1 { color: yellow; }
    (a) green (b) black (c) red (d) yellow
  19. 19.⚖️ What colour is the text of this element?
    <p class="menu" id="end">Hi</p>
    CSS:
    .menu { color: purple; }
    #end { color: black; }
    p { color: blue; }
    (a) purple (b) red (c) black (d) blue
  20. 20.🌈 Which hex code is red? (a) #ff00ff (b) #00ffff (c) #0000ff (d) #ff0000
  21. 21.🎯 Which sign starts an id selector? (a) # (b) & (c) @ (d) .
  22. 22.True or false: li is an element selector. (a) True (b) False
  23. 23.🎯 What kind of selector is .card? (a) an id selector (b) a class selector (c) an element selector
  24. 24.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      text-align: center;
      font-weight: bold;
      font-size: 20px;
    }
  25. 25.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 16px;
      }
    }
  26. 26.✍️ What value is given to font-size in this rule?
    p {
      font-size: 20px;
      font-weight: bold;
    }
    (a) 20px (b) font-size (c) center (d) yellow
  27. 27.🌈 Which colour is #ff00ff? (a) white (b) red (c) black (d) magenta
  28. 28.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 200px;
      padding: 20px;
      border: 5px solid black;
      margin: 15px;
    }
  29. 29.⚖️ What colour is the text of this element?
    <h1 class="box" id="top">Hi</h1>
    CSS:
    .box { color: black; }
    #top { color: white; }
    h1 { color: red; }
    (a) black (b) red (c) white (d) orange
  30. 30.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
  31. 31.What does font-size do? (a) makes letters bigger (b) colours behind the text (c) picks the font style (d) sets the letter colour
  32. 32.⚖️ What colour is the text of this element?
    <h2 class="red" id="end">Hi</h2>
    CSS:
    .red { color: white; }
    #end { color: red; }
    h2 { color: orange; }
    (a) red (b) black (c) orange (d) white
  33. 33.📱 Which tag helps phones show a page at the right size? (a) the title tag (b) the br tag (c) the viewport meta tag (d) the hr tag
  34. 34.True or false: .card is an id selector. (a) False (b) True
  35. 35.📦 In the box model, which part is the gap round content? (a) padding (b) content (c) border (d) margin
  36. 36.🎯 Which CSS selector matches this element?
    <li class="big" id="main">Hello</li>
    (a) li (b) #big (c) #logo (d) .main
  37. 37.✍️ What value is given to background-color in this rule?
    h1 {
      background-color: yellow;
      border: 2px solid;
    }
    (a) 10px (b) background-color (c) yellow (d) 8px
  38. 38.🌈 In #rrggbb, which colour do the last two digits give? (a) red (b) white (c) green (d) blue
  39. 39.🖌️ Where does the text sit on its line?
    p {
      font-size: 36px;
      background-color: yellow;
      text-align: left;
      color: blue;
    }
    (a) on the left (b) on the right (c) in the middle
  40. 40.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 220px;
      justify-content: flex-end;
    }
    Inside are 4 boxes, each 50px wide (no margins).

Answer key

  1. 4
  2. False
  3. cyan
  4. 4
  5. black
  6. font-weight
  7. color
  8. 18
  9. the screen width
  10. { }
  11. yellow
  12. .
  13. shows a pop-up message
  14. puts boxes in the middle
  15. #top
  16. #hero
  17. 28
  18. yellow
  19. black
  20. #ff0000
  21. #
  22. True
  23. a class selector
  24. 3
  25. 12
  26. 20px
  27. magenta
  28. 280
  29. white
  30. an element selector
  31. makes letters bigger
  32. red
  33. the viewport meta tag
  34. False
  35. padding
  36. li
  37. yellow
  38. blue
  39. on the left
  40. 20

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