← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 790 · 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.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 280px;
      padding: 30px;
      border: 2px solid black;
      margin: 5px;
    }
  2. 2.✍️ CSS declarations go inside which brackets? (a) ( ) (b) [ ] (c) < > (d) { }
  3. 3.⚖️ What colour is the text of this element?
    <h1 class="box" id="end">Hi</h1>
    CSS:
    h1 { color: yellow; }
    h1 { color: blue; }
    (a) black (b) blue (c) white (d) yellow
  4. 4.🖌️ What colour are the letters?
    li {
      font-size: 20px;
      background-color: white;
      text-align: left;
      color: orange;
    }
    (a) yellow (b) white (c) orange
  5. 5.🖌️ Which CSS property centres a heading? (a) background-color (b) font-weight (c) text-align (d) font-size
  6. 6.🌈 Which hex code is bright green? (a) #00ffff (b) #00ff00 (c) #ffff00 (d) #ff0000
  7. 7.🌈 Which colour of light is strongest in rgb(105, 160, 59)? (a) green (b) red (c) blue
  8. 8.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 140px;
      justify-content: center;
    }
    Inside are 2 boxes, each 60px wide (no margins).
  9. 9.📦 In the box model, which part is space inside the border? (a) padding (b) margin (c) border (d) content
  10. 10.⚖️ What colour is the text of this element?
    <p class="note" id="hero">Hi</p>
    CSS:
    p { color: orange; }
    p { color: yellow; }
    (a) orange (b) red (c) yellow (d) purple
  11. 11.🎨 Which attribute adds CSS inside one tag? (a) src (b) style (c) alt (d) href
  12. 12.✍️ Which property is set to 20px in this rule?
    h2 {
      padding: 8px;
      font-style: italic;
      font-size: 20px;
    }
    (a) 20px (b) text-align (c) background-color (d) font-size
  13. 13.🎯 Which CSS selector matches this element?
    <li class="red" id="end">Hello</li>
    (a) .box (b) #hero (c) #end (d) .end
  14. 14.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 190px;
      padding: 5px;
      border: 3px solid black;
      margin: 5px;
    }
  15. 15.✍️ What is the selector in this CSS rule?
    h1 {
      font-size: 20px;
      width: 300px;
    }
    (a) 300px (b) h1 (c) p (d) font-size
  16. 16.💪 Which flexbox property turns on flexbox? (a) display: flex (b) flex-direction (c) align-items (d) gap
  17. 17.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 80px;
      padding: 5px;
      border: 5px solid black;
      margin: 10px;
    }
  18. 18.📱 The screen is 700px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 20px;
      }
    }
    (a) No (b) Yes
  19. 19.🌈 Which hex code is magenta? (a) #00ff00 (b) #ff00ff (c) #ffff00 (d) #ff0000
  20. 20.⚖️ What colour is the text of this element?
    <h1 class="star" id="end">Hi</h1>
    CSS:
    .star { color: black; }
    .star { color: purple; }
    (a) black (b) yellow (c) purple (d) orange
  21. 21.True or false: the border is the line round the box. (a) False (b) True
  22. 22.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 180px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 80px wide (no margins).
  23. 23.🔍 Which is the odd one out? (a) makes headings and lists (b) puts a picture on a page (c) makes a form box (d) shows a pop-up message
  24. 24.⚖️ What colour is the text of this element?
    <h2 class="menu" id="main">Hi</h2>
    CSS:
    h2 { color: red; }
    #main { color: blue; }
    (a) blue (b) white (c) yellow (d) red
  25. 25.What does font-size do? (a) centres a heading (b) makes letters bigger (c) picks the font style (d) sets the letter colour
  26. 26.🖌️ What colour are the letters?
    h1 {
      background-color: orange;
      font-size: 16px;
      text-align: center;
      color: yellow;
    }
    (a) white (b) orange (c) yellow
  27. 27.🌈 Which hex code is red? (a) #ffffff (b) #0000ff (c) #ffff00 (d) #ff0000
  28. 28.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 280px;
      justify-content: center;
    }
    Inside are 3 boxes, each 80px wide (no margins).
  29. 29.✍️ Which property is set to 300px in this rule?
    #top {
      width: 300px;
      text-align: center;
    }
    (a) 300px (b) width (c) font-style (d) color
  30. 30.🖌️ What colour is behind the letters?
    h1 {
      background-color: black;
      font-size: 20px;
      text-align: right;
      color: purple;
    }
    (a) white (b) black (c) purple
  31. 31.✍️ Which property is set to yellow in this rule?
    li {
      margin: 10px;
      background-color: yellow;
    }
    (a) background-color (b) yellow (c) padding (d) margin
  32. 32.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 220px;
      padding: 25px;
      border: 5px solid black;
      margin: 15px;
    }
  33. 33.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 100px;
      padding: 20px;
      border: 3px solid black;
      margin: 0px;
    }
  34. 34.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 230px;
      justify-content: flex-start;
    }
    Inside are 3 boxes, each 60px wide (no margins).
  35. 35.Which of these does JavaScript do? (a) lays out the page (b) makes headings and lists (c) shows a pop-up message (d) puts a picture on a page
  36. 36.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 20px;
      }
    }
    (a) Yes (b) No
  37. 37.🎯 How many elements on a page should have the same id? (a) 5 (b) any number (c) 1 (d) 2
  38. 38.✍️ Which property is set to center in this rule?
    li {
      margin: 10px;
      text-align: center;
    }
    (a) text-align (b) background-color (c) center (d) margin
  39. 39.✍️ What is the selector in this CSS rule?
    #top {
      background-color: yellow;
      width: 300px;
      font-size: 20px;
      border: 2px solid;
    }
    (a) background-color (b) 300px (c) li (d) #top
  40. 40.True or false: JavaScript lays out the page. (a) False (b) True

Answer key

  1. 344
  2. { }
  3. blue
  4. orange
  5. text-align
  6. #00ff00
  7. green
  8. 10
  9. padding
  10. yellow
  11. style
  12. font-size
  13. #end
  14. 206
  15. h1
  16. display: flex
  17. 100
  18. No
  19. #ff00ff
  20. purple
  21. True
  22. 20
  23. shows a pop-up message
  24. blue
  25. makes letters bigger
  26. yellow
  27. #ff0000
  28. 20
  29. width
  30. black
  31. background-color
  32. 280
  33. 146
  34. 50
  35. shows a pop-up message
  36. No
  37. 1
  38. text-align
  39. #top
  40. False

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