← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 52 · 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.🎯 Which CSS selector matches this element?
    <div class="menu" id="logo">Hello</div>
    (a) span (b) #end (c) #menu (d) .menu
  2. 2.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 220px;
      padding: 25px;
      border: 5px solid black;
      margin: 10px;
    }
  3. 3.⚖️ What colour is the text of this element?
    <h2 class="note" id="main">Hi</h2>
    CSS:
    h2 { color: white; }
    .note { color: green; }
    (a) green (b) white (c) black (d) red
  4. 4.📱 Which tag helps phones show a page at the right size? (a) the hr tag (b) the br tag (c) the title tag (d) the viewport meta tag
  5. 5.✍️ What is the selector in this CSS rule?
    #top {
      padding: 8px;
      font-size: 20px;
    }
    (a) padding (b) 20px (c) #top (d) li
  6. 6.What does justify-content: center do? (a) puts boxes in the middle (b) packs boxes at the start (c) packs boxes at the end (d) equal gaps, none at ends
  7. 7.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      border: 2px solid;
    }
  8. 8.✍️ Which property is set to 8px in this rule?
    #top {
      padding: 8px;
      font-size: 20px;
    }
    (a) 8px (b) font-weight (c) padding (d) border
  9. 9.🖌️ What colour is behind the letters?
    li {
      font-size: 12px;
      color: blue;
      text-align: left;
      background-color: yellow;
    }
    (a) orange (b) yellow (c) blue
  10. 10.True or false: CSS changes the text size. (a) True (b) False
  11. 11.🎯 Can many elements share the same class? (a) No (b) Yes
  12. 12.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the first one (c) the later one (d) neither
  13. 13.🎨 One CSS file can style how many pages? (a) only one image (b) only one word (c) many pages (d) no pages
  14. 14.🌈 Which colour is #00ffff? (a) magenta (b) cyan (c) white (d) yellow
  15. 15.True or false: li is an id selector. (a) True (b) False
  16. 16.🎨 A CSS file usually ends with which extension? (a) .png (b) .html (c) .js (d) .css
  17. 17.What does font-weight do? (a) centres a heading (b) sets the letter colour (c) makes the text bold (d) colours behind the text
  18. 18.True or false: .star is a class selector. (a) False (b) True
  19. 19.⚖️ What colour is the text of this element?
    <h1 class="note" id="top">Hi</h1>
    CSS:
    #top { color: red; }
    h1 { color: orange; }
    (a) orange (b) red (c) purple (d) white
  20. 20.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 4 (b) 2 (c) 6 (d) 3
  21. 21.⚖️ What colour is the text of this element?
    <p class="big" id="top">Hi</p>
    CSS:
    #top { color: orange; }
    #top { color: yellow; }
    (a) yellow (b) purple (c) orange (d) red
  22. 22.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 10px;
      }
    }
  23. 23.✍️ What is the selector in this CSS rule?
    body {
      width: 300px;
      background-color: yellow;
    }
    (a) body (b) width (c) .box (d) yellow
  24. 24.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      background-color: yellow;
      width: 300px;
    }
  25. 25.🎯 Which element does the selector p style? (a) <h1> (b) <li id="main"> (c) <p class="star"> (d) <h2 class="star">
  26. 26.🌈 In #00af00 the green part is the hex number af. What is it as a normal number?
  27. 27.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 250px;
      justify-content: flex-start;
    }
    Inside are 3 boxes, each 80px wide (no margins).
  28. 28.✍️ Which sign goes between a property and its value? (a) = (b) ; (c) - (d) :
  29. 29.🎯 Which CSS selector matches this element?
    <span class="menu" id="main">Hello</span>
    (a) #logo (b) p (c) .menu (d) .note
  30. 30.🎯 Which CSS selector matches this element?
    <li class="note" id="intro">Hello</li>
    (a) div (b) .intro (c) #intro (d) .big
  31. 31.What does justify-content: flex-end 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
  32. 32.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) red (c) blue (d) white
  33. 33.⚖️ What colour is the text of this element?
    <p class="star" id="logo">Hi</p>
    CSS:
    p { color: yellow; }
    p { color: blue; }
    (a) orange (b) red (c) yellow (d) blue
  34. 34.🖌️ How big is the text, in px?
    h1 {
      color: green;
      text-align: center;
      background-color: blue;
      font-size: 28px;
    }
  35. 35.🌈 In #c10000 the red part is the hex number c1. What is it as a normal number?
  36. 36.Which of these is the content? (a) a solid or dotted edge (b) the gap round content (c) the text or picture (d) the gap to other boxes
  37. 37.🎯 Which sign starts a class selector? (a) . (b) @ (c) # (d) &
  38. 38.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 28px;
      }
    }
    (a) Yes (b) No
  39. 39.🧩 Which language adds space around boxes? (a) CSS (b) JavaScript (c) HTML
  40. 40.✍️ In color: blue; which part is the property? (a) color (b) : (c) ; (d) blue

Answer key

  1. .menu
  2. 300
  3. green
  4. the viewport meta tag
  5. #top
  6. puts boxes in the middle
  7. 1
  8. padding
  9. yellow
  10. True
  11. Yes
  12. the later one
  13. many pages
  14. cyan
  15. False
  16. .css
  17. makes the text bold
  18. True
  19. red
  20. 3
  21. yellow
  22. 10
  23. body
  24. 2
  25. <p class="star">
  26. 175
  27. 10
  28. :
  29. .menu
  30. #intro
  31. packs boxes at the end
  32. blue
  33. blue
  34. 28
  35. 193
  36. the text or picture
  37. .
  38. No
  39. CSS
  40. color

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