← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 717 · 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 does text-align do? (a) picks the font style (b) centres a heading (c) sets the letter colour (d) colours behind the text
  2. 2.📱 Responsive design means a page ___. (a) fits every screen (b) never changes (c) has no pictures (d) is only for laptops
  3. 3.True or false: the border is the line round the box. (a) True (b) False
  4. 4.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      width: 300px;
      font-size: 20px;
      border: 2px solid;
    }
  5. 5.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 24px;
      }
    }
  6. 6.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the later one (c) the first one (d) the shorter one
  7. 7.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 6px;
      }
    }
  8. 8.🎯 What kind of selector is h1? (a) an element selector (b) a class selector (c) an id selector
  9. 9.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 70px;
      padding: 25px;
      border: 2px solid black;
      margin: 10px;
    }
  10. 10.⚖️ What colour is the text of this element?
    <h2 class="box" id="main">Hi</h2>
    CSS:
    h2 { color: orange; }
    h2 { color: red; }
    (a) purple (b) red (c) yellow (d) orange
  11. 11.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
  12. 12.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 20px;
      }
    }
  13. 13.✍️ What value is given to background-color in this rule?
    p {
      text-align: center;
      color: red;
      font-size: 20px;
      background-color: yellow;
    }
    (a) 8px (b) yellow (c) background-color (d) 10px
  14. 14.🖌️ Which CSS property makes the text bold? (a) font-weight (b) color (c) background-color (d) text-align
  15. 15.🖌️ How big is the text, in px?
    li {
      background-color: orange;
      color: green;
      font-size: 24px;
      text-align: right;
    }
  16. 16.🖌️ What colour are the letters?
    li {
      color: yellow;
      text-align: center;
      font-size: 20px;
      background-color: blue;
    }
    (a) yellow (b) black (c) blue
  17. 17.✍️ What is the selector in this CSS rule?
    .box {
      width: 300px;
      border: 2px solid;
      padding: 8px;
    }
    (a) h2 (b) .box (c) width (d) 2px solid
  18. 18.🧩 Which language adds space around boxes? (a) CSS (b) HTML (c) JavaScript
  19. 19.💪 Which flexbox property sets space between boxes? (a) gap (b) display: flex (c) align-items (d) flex-direction
  20. 20.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 30px;
      }
    }
  21. 21.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 18px;
      }
    }
  22. 22.🖌️ Where does the text sit on its line?
    li {
      color: red;
      text-align: center;
      font-size: 12px;
      background-color: green;
    }
    (a) on the right (b) in the middle (c) on the left
  23. 23.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 22px;
      }
    }
  24. 24.🧩 Which language lays out the page? (a) CSS (b) HTML (c) JavaScript
  25. 25.🌈 Which colour is #ff0000? (a) magenta (b) blue (c) red (d) white
  26. 26.📱 The screen is 540px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 18px;
      }
    }
    (a) Yes (b) No
  27. 27.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 150px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 60px wide (no margins).
  28. 28.🖌️ Which CSS property sets the letter colour? (a) background-color (b) color (c) font-family (d) font-weight
  29. 29.💪 Which flexbox property lines boxes up across? (a) flex-direction (b) display: flex (c) justify-content (d) align-items
  30. 30.📱 Which tag helps phones show a page at the right size? (a) the br tag (b) the viewport meta tag (c) the hr tag (d) the title tag
  31. 31.🌈 In #050000 the red part is the hex number 05. What is it as a normal number?
  32. 32.💪 Which justify-content value puts boxes in the middle? (a) space-between (b) center (c) flex-end (d) flex-start
  33. 33.What does font-size do? (a) sets the letter colour (b) makes letters bigger (c) picks the font style (d) colours behind the text
  34. 34.True or false: the content is the line round the box. (a) True (b) False
  35. 35.🖌️ Where does the text sit on its line?
    li {
      text-align: left;
      color: black;
      background-color: purple;
      font-size: 24px;
    }
    (a) on the left (b) on the right (c) in the middle
  36. 36.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) red (c) blue (d) white
  37. 37.🖌️ Which CSS property centres a heading? (a) background-color (b) font-size (c) text-align (d) font-family
  38. 38.True or false: img is an element selector. (a) False (b) True
  39. 39.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      width: 300px;
      font-style: italic;
    }
  40. 40.Which of these is the border? (a) a solid or dotted edge (b) space outside the border (c) the text or picture (d) the gap to other boxes

Answer key

  1. centres a heading
  2. fits every screen
  3. True
  4. 3
  5. 20
  6. the later one
  7. 6
  8. an element selector
  9. 144
  10. red
  11. an element selector
  12. 20
  13. yellow
  14. font-weight
  15. 24
  16. yellow
  17. .box
  18. CSS
  19. gap
  20. 24
  21. 20
  22. in the middle
  23. 24
  24. CSS
  25. red
  26. No
  27. 30
  28. color
  29. align-items
  30. the viewport meta tag
  31. 5
  32. center
  33. makes letters bigger
  34. False
  35. on the left
  36. blue
  37. text-align
  38. True
  39. 2
  40. a solid or dotted edge

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