← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 209 · 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 value is given to padding in this rule?
    h1 {
      padding: 8px;
      border: 2px solid;
      width: 300px;
      font-weight: bold;
    }
    (a) bold (b) padding (c) 8px (d) 2px solid
  2. 2.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      background-color: yellow;
      font-style: italic;
      font-size: 20px;
      text-align: center;
    }
  3. 3.Which of these does HTML do? (a) lays out the page (b) checks a quiz answer (c) puts a picture on a page (d) reacts to a button click
  4. 4.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 22px;
      }
    }
  5. 5.🌈 In #00f400 the green part is the hex number f4. What is it as a normal number?
  6. 6.🖌️ What colour is behind the letters?
    h1 {
      font-size: 28px;
      text-align: center;
      background-color: yellow;
      color: blue;
    }
    (a) yellow (b) green (c) blue
  7. 7.🌈 Which colour is rgb(255, 0, 255)? (a) magenta (b) black (c) cyan (d) bright green
  8. 8.💪 Which justify-content value packs boxes at the end? (a) flex-end (b) flex-start (c) center (d) space-between
  9. 9.🌈 In #800000 the red part is the hex number 80. What is it as a normal number?
  10. 10.🖌️ How big is the text, in px?
    p {
      background-color: green;
      font-size: 20px;
      text-align: center;
      color: blue;
    }
  11. 11.What does justify-content: flex-start 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
  12. 12.True or false: HTML makes headings and lists. (a) True (b) False
  13. 13.📦 In the box model, which part is the line round the box? (a) content (b) padding (c) margin (d) border
  14. 14.⚖️ What colour is the text of this element?
    <p class="note" id="intro">Hi</p>
    CSS:
    .note { color: red; }
    .note { color: green; }
    (a) red (b) purple (c) green (d) blue
  15. 15.🎯 Which CSS selector matches this element?
    <h1 class="star" id="hero">Hello</h1>
    (a) h2 (b) .menu (c) #star (d) #hero
  16. 16.💪 Which flexbox property turns on flexbox? (a) justify-content (b) gap (c) display: flex (d) align-items
  17. 17.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
  18. 18.🖌️ Which CSS property sets the letter colour? (a) color (b) font-family (c) text-align (d) font-weight
  19. 19.📱 The screen is 375px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 22px;
      }
    }
    (a) No (b) Yes
  20. 20.✍️ CSS declarations go inside which brackets? (a) < > (b) { } (c) [ ] (d) ( )
  21. 21.🖌️ Where does the text sit on its line?
    h2 {
      background-color: black;
      text-align: right;
      font-size: 24px;
      color: yellow;
    }
    (a) on the right (b) on the left (c) in the middle
  22. 22.🌈 Which hex code is black? (a) #00ffff (b) #ff00ff (c) #000000 (d) #0000ff
  23. 23.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 180px;
      justify-content: flex-end;
    }
    Inside are 4 boxes, each 40px wide (no margins).
  24. 24.💪 Which flexbox property picks row or column? (a) align-items (b) display: flex (c) gap (d) flex-direction
  25. 25.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 28px;
      }
    }
    (a) No (b) Yes
  26. 26.📱 The screen is 1366px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 18px;
      }
    }
    (a) No (b) Yes
  27. 27.True or false: JavaScript puts a picture on a page. (a) False (b) True
  28. 28.⚖️ What colour is the text of this element?
    <p class="star" id="intro">Hi</p>
    CSS:
    .star { color: black; }
    #intro { color: green; }
    p { color: yellow; }
    (a) green (b) yellow (c) black (d) orange
  29. 29.💪 Which justify-content value packs boxes at the start? (a) center (b) space-between (c) flex-start (d) flex-end
  30. 30.🎯 Can many elements share the same class? (a) No (b) Yes
  31. 31.🖌️ Which CSS property colours behind the text? (a) background-color (b) color (c) font-weight (d) font-family
  32. 32.⚖️ What colour is the text of this element?
    <h2 class="box" id="main">Hi</h2>
    CSS:
    .box { color: green; }
    .box { color: yellow; }
    (a) yellow (b) red (c) white (d) green
  33. 33.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 190px;
      padding: 20px;
      border: 4px solid black;
      margin: 0px;
    }
  34. 34.🎯 What kind of selector is li? (a) a class selector (b) an element selector (c) an id selector
  35. 35.🌈 In #000072 the blue part is the hex number 72. What is it as a normal number?
  36. 36.📦 In the box model, which part is space outside the border? (a) border (b) padding (c) content (d) margin
  37. 37.True or false: img is an id selector. (a) True (b) False
  38. 38.True or false: CSS sets colours and fonts. (a) True (b) False
  39. 39.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 20px;
      }
    }
  40. 40.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      text-align: center;
      border: 2px solid;
      font-style: italic;
    }

Answer key

  1. 8px
  2. 4
  3. puts a picture on a page
  4. 22
  5. 244
  6. yellow
  7. magenta
  8. flex-end
  9. 128
  10. 20
  11. packs boxes at the start
  12. True
  13. border
  14. green
  15. #hero
  16. display: flex
  17. an element selector
  18. color
  19. Yes
  20. { }
  21. on the right
  22. #000000
  23. 20
  24. flex-direction
  25. No
  26. No
  27. False
  28. green
  29. flex-start
  30. Yes
  31. background-color
  32. yellow
  33. 238
  34. an element selector
  35. 114
  36. margin
  37. False
  38. True
  39. 20
  40. 3

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