← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 171 · 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 colour is the text of this element?
    <p class="star" id="hero">Hi</p>
    CSS:
    p { color: blue; }
    #hero { color: purple; }
    .star { color: black; }
    (a) orange (b) purple (c) black (d) blue
  2. 2.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the later one (c) neither (d) the first one
  3. 3.🌈 Which colour is rgb(0, 255, 0)? (a) cyan (b) blue (c) bright green (d) yellow
  4. 4.✍️ How many declarations (property: value pairs) are in this rule?
    #top {
      margin: 10px;
      color: red;
      font-style: italic;
    }
  5. 5.🖌️ Which CSS property colours behind the text? (a) text-align (b) font-size (c) color (d) background-color
  6. 6.⚖️ Which selector is the weakest? (a) an element selector (b) a class selector (c) an id selector
  7. 7.💪 Which flexbox property spaces boxes along a row? (a) flex-direction (b) gap (c) justify-content (d) align-items
  8. 8.Which of these does CSS do? (a) checks a quiz answer (b) adds space around boxes (c) counts down a timer (d) makes headings and lists
  9. 9.⚖️ What colour is the text of this element?
    <h2 class="red" id="main">Hi</h2>
    CSS:
    #main { color: blue; }
    .red { color: orange; }
    h2 { color: white; }
    (a) orange (b) white (c) blue (d) red
  10. 10.🌈 Which colour is #ffffff? (a) magenta (b) yellow (c) white (d) bright green
  11. 11.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 160px;
      padding: 10px;
      border: 4px solid black;
      margin: 20px;
    }
  12. 12.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      background-color: yellow;
    }
  13. 13.🌈 Which colour of light is strongest in rgb(30, 107, 224)? (a) blue (b) green (c) red
  14. 14.What does justify-content: center do? (a) packs boxes at the end (b) puts boxes in the middle (c) equal gaps, none at ends (d) packs boxes at the start
  15. 15.🎨 Which tag holds CSS inside the head? (a) <body> (b) <css> (c) <script> (d) <style>
  16. 16.📱 The screen is 1100px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 26px;
      }
    }
    (a) No (b) Yes
  17. 17.⚖️ What colour is the text of this element?
    <h2 class="big" id="intro">Hi</h2>
    CSS:
    #intro { color: purple; }
    #intro { color: orange; }
    (a) black (b) yellow (c) orange (d) purple
  18. 18.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 16px;
      }
    }
    (a) Yes (b) No
  19. 19.🖌️ What colour is behind the letters?
    h1 {
      background-color: purple;
      text-align: right;
      color: blue;
      font-size: 24px;
    }
    (a) blue (b) purple (c) yellow
  20. 20.💪 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).
  21. 21.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 24px;
      }
    }
  22. 22.⚖️ What colour is the text of this element?
    <p class="big" id="top">Hi</p>
    CSS:
    .big { color: red; }
    .big { color: green; }
    (a) white (b) green (c) blue (d) red
  23. 23.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 70px;
      padding: 25px;
      border: 1px solid black;
      margin: 0px;
    }
  24. 24.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 140px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 60px wide (no margins).
  25. 25.✍️ What is the selector in this CSS rule?
    h1 {
      font-size: 20px;
      background-color: yellow;
      font-weight: bold;
    }
    (a) p (b) yellow (c) font-size (d) h1
  26. 26.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) red (c) blue (d) white
  27. 27.What does font-family do? (a) picks the font style (b) makes the text bold (c) centres a heading (d) makes letters bigger
  28. 28.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 50px;
      padding: 15px;
      border: 4px solid black;
      margin: 10px;
    }
  29. 29.✍️ Which property is set to 2px solid in this rule?
    h2 {
      width: 300px;
      border: 2px solid;
      font-size: 20px;
    }
    (a) font-style (b) border (c) width (d) 2px solid
  30. 30.True or false: margin is space outside the border. (a) True (b) False
  31. 31.✍️ How does a CSS comment start? (a) // (b) # (c) /* (d) <!--
  32. 32.🧩 Which language sets colours and fonts? (a) JavaScript (b) CSS (c) HTML
  33. 33.💪 Which justify-content value puts boxes in the middle? (a) flex-start (b) flex-end (c) space-between (d) center
  34. 34.🎯 Can many elements share the same class? (a) No (b) Yes
  35. 35.🖌️ How big is the text, in px?
    h2 {
      background-color: orange;
      color: red;
      font-size: 32px;
      text-align: center;
    }
  36. 36.⚖️ What colour is the text of this element?
    <p class="big" id="end">Hi</p>
    CSS:
    .big { color: blue; }
    .big { color: orange; }
    (a) purple (b) white (c) orange (d) blue
  37. 37.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 2 (b) 4 (c) 3 (d) 6
  38. 38.🌈 Which colour is rgb(0, 0, 255)? (a) bright green (b) white (c) yellow (d) blue
  39. 39.True or false: #main is an id selector. (a) True (b) False
  40. 40.🌈 Which hex code is bright green? (a) #00ffff (b) #00ff00 (c) #ffff00 (d) #0000ff

Answer key

  1. purple
  2. the later one
  3. bright green
  4. 3
  5. background-color
  6. an element selector
  7. justify-content
  8. adds space around boxes
  9. blue
  10. white
  11. 188
  12. 1
  13. blue
  14. puts boxes in the middle
  15. <style>
  16. Yes
  17. orange
  18. Yes
  19. purple
  20. 10
  21. 16
  22. green
  23. 122
  24. 20
  25. h1
  26. blue
  27. picks the font style
  28. 108
  29. border
  30. True
  31. /*
  32. CSS
  33. center
  34. Yes
  35. 32
  36. orange
  37. 3
  38. blue
  39. True
  40. #00ff00

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