← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 232 · 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="box" id="end">Hi</p>
    CSS:
    p { color: yellow; }
    #end { color: white; }
    (a) blue (b) white (c) orange (d) yellow
  2. 2.📱 Which tag helps phones show a page at the right size? (a) the hr tag (b) the title tag (c) the br tag (d) the viewport meta tag
  3. 3.True or false: .star is a class selector. (a) True (b) False
  4. 4.📱 The screen is 540px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 14px;
      }
    }
    (a) No (b) Yes
  5. 5.⚖️ What colour is the text of this element?
    <h2 class="star" id="top">Hi</h2>
    CSS:
    h2 { color: yellow; }
    h2 { color: red; }
    (a) red (b) white (c) yellow (d) orange
  6. 6.✍️ Which property is set to 8px in this rule?
    .box {
      text-align: center;
      padding: 8px;
      background-color: yellow;
    }
    (a) 8px (b) padding (c) border (d) font-weight
  7. 7.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the first one (c) the later one (d) the shorter one
  8. 8.⚖️ What colour is the text of this element?
    <p class="star" id="logo">Hi</p>
    CSS:
    #logo { color: purple; }
    p { color: orange; }
    .star { color: white; }
    (a) orange (b) yellow (c) purple (d) white
  9. 9.True or false: margin is a solid or dotted edge. (a) False (b) True
  10. 10.✍️ Which property is set to 300px in this rule?
    li {
      text-align: center;
      border: 2px solid;
      width: 300px;
    }
    (a) 300px (b) color (c) font-style (d) width
  11. 11.🖌️ How big is the text, in px?
    h2 {
      background-color: blue;
      text-align: right;
      font-size: 36px;
      color: red;
    }
  12. 12.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 100px;
      padding: 10px;
      border: 1px solid black;
      margin: 20px;
    }
  13. 13.True or false: .note is a class selector. (a) False (b) True
  14. 14.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 260px;
      justify-content: flex-start;
    }
    Inside are 3 boxes, each 60px wide (no margins).
  15. 15.True or false: HTML sets colours and fonts. (a) False (b) True
  16. 16.🎯 Which element does the selector p style? (a) <p class="big"> (b) <h1> (c) <h2 class="big"> (d) <li id="top">
  17. 17.🎯 Which CSS selector matches this element?
    <p class="big" id="main">Hello</p>
    (a) #big (b) h1 (c) .big (d) .main
  18. 18.🎯 What kind of selector is .big? (a) a class selector (b) an id selector (c) an element selector
  19. 19.True or false: the border is the text or picture. (a) False (b) True
  20. 20.⚖️ What colour is the text of this element?
    <h2 class="note" id="top">Hi</h2>
    CSS:
    #top { color: yellow; }
    #top { color: white; }
    (a) white (b) yellow (c) purple (d) black
  21. 21.🌈 Which colour of light is strongest in rgb(166, 124, 13)? (a) green (b) red (c) blue
  22. 22.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) turned off (c) 600px or narrower (d) 600px or wider
  23. 23.🧩 Which language makes headings and lists? (a) HTML (b) JavaScript (c) CSS
  24. 24.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 250px;
      justify-content: flex-start;
    }
    Inside are 4 boxes, each 60px wide (no margins).
  25. 25.🌈 Which colour is rgb(0, 0, 0)? (a) yellow (b) black (c) blue (d) cyan
  26. 26.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 170px;
      justify-content: space-between;
    }
    Inside are 2 boxes, each 80px wide (no margins).
  27. 27.What does justify-content: space-between do? (a) packs boxes at the end (b) puts boxes in the middle (c) packs boxes at the start (d) equal gaps, none at ends
  28. 28.🎯 What kind of selector is #hero? (a) an element selector (b) an id selector (c) a class selector
  29. 29.⚖️ What colour is the text of this element?
    <h1 class="box" id="hero">Hi</h1>
    CSS:
    .box { color: black; }
    h1 { color: blue; }
    (a) green (b) blue (c) orange (d) black
  30. 30.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 260px;
      justify-content: flex-end;
    }
    Inside are 2 boxes, each 100px wide (no margins).
  31. 31.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      background-color: yellow;
      font-size: 20px;
      border: 2px solid;
    }
  32. 32.🖌️ What colour are the letters?
    p {
      color: red;
      text-align: center;
      font-size: 32px;
      background-color: black;
    }
    (a) black (b) orange (c) red
  33. 33.🎯 What kind of selector is .note? (a) a class selector (b) an id selector (c) an element selector
  34. 34.✍️ Which property is set to 20px in this rule?
    li {
      font-size: 20px;
      border: 2px solid;
    }
    (a) text-align (b) font-size (c) background-color (d) 20px
  35. 35.True or false: #hero is an id selector. (a) False (b) True
  36. 36.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
  37. 37.True or false: HTML checks a quiz answer. (a) False (b) True
  38. 38.What does justify-content: flex-end do? (a) equal gaps, none at ends (b) puts boxes in the middle (c) packs boxes at the start (d) packs boxes at the end
  39. 39.💪 Which flexbox property turns on flexbox? (a) flex-direction (b) justify-content (c) gap (d) display: flex
  40. 40.✍️ What is the selector in this CSS rule?
    p {
      font-weight: bold;
      text-align: center;
      background-color: yellow;
    }
    (a) center (b) font-weight (c) .note (d) p

Answer key

  1. white
  2. the viewport meta tag
  3. True
  4. Yes
  5. red
  6. padding
  7. the later one
  8. purple
  9. False
  10. width
  11. 36
  12. 162
  13. True
  14. 80
  15. False
  16. <p class="big">
  17. .big
  18. a class selector
  19. False
  20. white
  21. red
  22. 600px or narrower
  23. HTML
  24. 10
  25. black
  26. 10
  27. equal gaps, none at ends
  28. an id selector
  29. black
  30. 60
  31. 3
  32. red
  33. a class selector
  34. font-size
  35. True
  36. packs boxes at the start
  37. False
  38. packs boxes at the end
  39. display: flex
  40. p

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