← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 400 · 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.📱 The screen is 820px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 26px;
      }
    }
    (a) Yes (b) No
  2. 2.🖌️ Which CSS property colours behind the text? (a) font-family (b) font-weight (c) color (d) background-color
  3. 3.⚖️ 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
  4. 4.✍️ How many declarations (property: value pairs) are in this rule?
    li {
      border: 2px solid;
      color: red;
    }
  5. 5.💪 Which flexbox property spaces boxes along a row? (a) gap (b) display: flex (c) justify-content (d) flex-direction
  6. 6.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 280px;
      justify-content: space-between;
    }
    Inside are 3 boxes, each 60px wide (no margins).
  7. 7.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      text-align: center;
      color: red;
    }
  8. 8.True or false: margin is space inside the border. (a) False (b) True
  9. 9.🔍 Which is the odd one out? (a) gives the page structure (b) makes a link (c) changes the page live (d) makes a form box
  10. 10.📦 In the box model, which part is a solid or dotted edge? (a) padding (b) margin (c) content (d) border
  11. 11.💪 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).
  12. 12.🖌️ Where does the text sit on its line?
    h2 {
      text-align: right;
      font-size: 40px;
      color: orange;
      background-color: black;
    }
    (a) on the left (b) in the middle (c) on the right
  13. 13.⚖️ What colour is the text of this element?
    <h2 class="note" id="logo">Hi</h2>
    CSS:
    #logo { color: red; }
    .note { color: purple; }
    h2 { color: white; }
    (a) orange (b) white (c) purple (d) red
  14. 14.🎯 What kind of selector is #top? (a) an id selector (b) an element selector (c) a class selector
  15. 15.📱 Responsive design means a page ___. (a) fits every screen (b) is only for laptops (c) never changes (d) has no pictures
  16. 16.🌈 In #000095 the blue part is the hex number 95. What is it as a normal number?
  17. 17.⚖️ What colour is the text of this element?
    <h1 class="red" id="top">Hi</h1>
    CSS:
    h1 { color: white; }
    .red { color: purple; }
    #top { color: black; }
    (a) purple (b) yellow (c) white (d) black
  18. 18.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 80px;
      padding: 10px;
      border: 3px solid black;
      margin: 10px;
    }
  19. 19.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 250px;
      padding: 30px;
      border: 5px solid black;
      margin: 15px;
    }
  20. 20.True or false: HTML changes the text size. (a) True (b) False
  21. 21.🖌️ What colour are the letters?
    h2 {
      background-color: orange;
      font-size: 28px;
      text-align: right;
      color: white;
    }
    (a) red (b) white (c) orange
  22. 22.🌈 Which colour is #ff0000? (a) white (b) bright green (c) blue (d) red
  23. 23.✍️ Which property is set to yellow in this rule?
    p {
      width: 300px;
      background-color: yellow;
      border: 2px solid;
    }
    (a) yellow (b) padding (c) margin (d) background-color
  24. 24.💪 Which flexbox property sets space between boxes? (a) display: flex (b) gap (c) flex-direction (d) align-items
  25. 25.🎯 Which CSS selector matches this element?
    <div class="menu" id="end">Hello</div>
    (a) .note (b) span (c) div (d) .end
  26. 26.🌈 Which colour of light is strongest in rgb(62, 180, 101)? (a) blue (b) green (c) red
  27. 27.🌈 Which colour is #ff00ff? (a) bright green (b) yellow (c) magenta (d) cyan
  28. 28.🌈 Which colour of light is strongest in rgb(194, 100, 85)? (a) blue (b) green (c) red
  29. 29.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 160px;
      padding: 20px;
      border: 4px solid black;
      margin: 15px;
    }
  30. 30.🌈 Hex digits go 0 to 9, then A to which letter? (a) G (b) Z (c) J (d) F
  31. 31.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 14px;
      }
    }
  32. 32.🌈 Which hex code is magenta? (a) #ff0000 (b) #ffff00 (c) #ff00ff (d) #00ff00
  33. 33.True or false: .menu is a class selector. (a) True (b) False
  34. 34.🖌️ What colour is behind the letters?
    h1 {
      background-color: orange;
      font-size: 24px;
      color: green;
      text-align: left;
    }
    (a) orange (b) yellow (c) green
  35. 35.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 70px;
      padding: 20px;
      border: 4px solid black;
      margin: 15px;
    }
  36. 36.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      background-color: yellow;
      text-align: center;
    }
  37. 37.📦 In the box model, which part is the line round the box? (a) padding (b) border (c) margin (d) content
  38. 38.✍️ How does a CSS comment start? (a) # (b) /* (c) <!-- (d) //
  39. 39.🎯 How many elements on a page should have the same id? (a) 2 (b) any number (c) 5 (d) 1
  40. 40.🎯 Which element does the selector h1 style? (a) <h2> (b) <h1 class="red"> (c) <div id="hero"> (d) <li class="red">

Answer key

  1. No
  2. background-color
  3. the later one
  4. 2
  5. justify-content
  6. 50
  7. 2
  8. False
  9. changes the page live
  10. border
  11. 80
  12. on the right
  13. red
  14. an id selector
  15. fits every screen
  16. 149
  17. black
  18. 126
  19. 350
  20. False
  21. white
  22. red
  23. background-color
  24. gap
  25. div
  26. green
  27. magenta
  28. red
  29. 238
  30. F
  31. 20
  32. #ff00ff
  33. True
  34. orange
  35. 148
  36. 2
  37. border
  38. /*
  39. 1
  40. <h1 class="red">

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