← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 122 · 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.🌈 Hex digits go 0 to 9, then A to which letter? (a) Z (b) F (c) G (d) J
  2. 2.🌈 Which colour is #ff0000? (a) red (b) white (c) bright green (d) magenta
  3. 3.🎯 Which sign starts an id selector? (a) & (b) @ (c) # (d) .
  4. 4.🌈 Which colour of light is strongest in rgb(235, 112, 26)? (a) green (b) blue (c) red
  5. 5.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 280px;
      padding: 20px;
      border: 3px solid black;
      margin: 5px;
    }
  6. 6.True or false: .star is a class selector. (a) True (b) False
  7. 7.✍️ What is the selector in this CSS rule?
    p {
      font-weight: bold;
      width: 300px;
      text-align: center;
    }
    (a) p (b) .note (c) font-weight (d) 300px
  8. 8.⚖️ What colour is the text of this element?
    <p class="big" id="intro">Hi</p>
    CSS:
    .big { color: white; }
    .big { color: blue; }
    (a) white (b) red (c) black (d) blue
  9. 9.🎯 Which element does the selector div style? (a) <div class="note"> (b) <p class="note"> (c) <span> (d) <h1 id="hero">
  10. 10.💪 Which justify-content value equal gaps, none at ends? (a) flex-start (b) flex-end (c) space-between (d) center
  11. 11.True or false: CSS changes the text size. (a) True (b) False
  12. 12.⚖️ What colour is the text of this element?
    <h1 class="star" id="hero">Hi</h1>
    CSS:
    .star { color: white; }
    .star { color: orange; }
    (a) orange (b) red (c) white (d) purple
  13. 13.🖌️ What colour are the letters?
    h1 {
      font-size: 36px;
      text-align: center;
      background-color: purple;
      color: red;
    }
    (a) red (b) blue (c) purple
  14. 14.What does color do? (a) picks the font style (b) sets the letter colour (c) centres a heading (d) makes letters bigger
  15. 15.⚖️ What colour is the text of this element?
    <h1 class="big" id="hero">Hi</h1>
    CSS:
    #hero { color: orange; }
    #hero { color: red; }
    (a) red (b) green (c) white (d) orange
  16. 16.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 70px;
      padding: 15px;
      border: 4px solid black;
      margin: 5px;
    }
  17. 17.What does justify-content: flex-end do? (a) equal gaps, none at ends (b) packs boxes at the start (c) puts boxes in the middle (d) packs boxes at the end
  18. 18.True or false: padding is space inside the border. (a) True (b) False
  19. 19.🎨 Which tag holds CSS inside the head? (a) <css> (b) <script> (c) <body> (d) <style>
  20. 20.📱 Which tag helps phones show a page at the right size? (a) the viewport meta tag (b) the title tag (c) the hr tag (d) the br tag
  21. 21.True or false: li is an id selector. (a) True (b) False
  22. 22.🖌️ Which CSS property makes letters bigger? (a) color (b) text-align (c) font-family (d) font-size
  23. 23.⚖️ What colour is the text of this element?
    <h2 class="menu" id="intro">Hi</h2>
    CSS:
    .menu { color: black; }
    #intro { color: blue; }
    (a) black (b) orange (c) white (d) blue
  24. 24.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 230px;
      justify-content: flex-end;
    }
    Inside are 4 boxes, each 40px wide (no margins).
  25. 25.✍️ How does a CSS comment start? (a) # (b) /* (c) // (d) <!--
  26. 26.What does font-weight do? (a) colours behind the text (b) makes the text bold (c) picks the font style (d) sets the letter colour
  27. 27.📱 What does a media query check? (a) the time of day (b) the screen width (c) the battery level (d) the page title
  28. 28.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
  29. 29.🖌️ Which CSS property centres a heading? (a) text-align (b) color (c) font-size (d) font-weight
  30. 30.📦 In the box model, which part is space outside the border? (a) padding (b) content (c) margin (d) border
  31. 31.🖌️ What colour is behind the letters?
    li {
      text-align: left;
      background-color: green;
      font-size: 32px;
      color: purple;
    }
    (a) purple (b) green (c) black
  32. 32.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 26px;
      }
    }
  33. 33.📱 The screen is 820px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 14px;
      }
    }
    (a) No (b) Yes
  34. 34.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the later one (c) the shorter one (d) the first one
  35. 35.True or false: #top is an id selector. (a) True (b) False
  36. 36.✍️ What is the selector in this CSS rule?
    .box {
      background-color: yellow;
      padding: 8px;
    }
    (a) h2 (b) 8px (c) background-color (d) .box
  37. 37.🌈 Which colour of light is strongest in rgb(26, 227, 45)? (a) blue (b) red (c) green
  38. 38.🌈 In #002b00 the green part is the hex number 2b. What is it as a normal number?
  39. 39.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 14px;
      }
    }
  40. 40.🧩 Which language changes the text size? (a) CSS (b) JavaScript (c) HTML

Answer key

  1. F
  2. red
  3. #
  4. red
  5. 326
  6. True
  7. p
  8. blue
  9. <div class="note">
  10. space-between
  11. True
  12. orange
  13. red
  14. sets the letter colour
  15. red
  16. 118
  17. packs boxes at the end
  18. True
  19. <style>
  20. the viewport meta tag
  21. False
  22. font-size
  23. blue
  24. 70
  25. /*
  26. makes the text bold
  27. the screen width
  28. an element selector
  29. text-align
  30. margin
  31. green
  32. 24
  33. No
  34. the later one
  35. True
  36. .box
  37. green
  38. 43
  39. 12
  40. CSS

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