← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 757 · 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.🖌️ Where does the text sit on its line?
    p {
      text-align: left;
      background-color: green;
      color: purple;
      font-size: 40px;
    }
    (a) in the middle (b) on the left (c) on the right
  2. 2.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 8px;
      }
    }
  3. 3.✍️ Which sign goes between a property and its value? (a) - (b) = (c) ; (d) :
  4. 4.🧩 Which language puts a picture on a page? (a) JavaScript (b) HTML (c) CSS
  5. 5.🌈 Which colour is rgb(0, 0, 0)? (a) black (b) bright green (c) magenta (d) blue
  6. 6.✍️ What is the selector in this CSS rule?
    body {
      font-style: italic;
      padding: 8px;
      font-weight: bold;
    }
    (a) .box (b) font-style (c) 8px (d) body
  7. 7.✍️ CSS declarations go inside which brackets? (a) { } (b) [ ] (c) < > (d) ( )
  8. 8.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 460px;
      justify-content: flex-start;
    }
    Inside are 4 boxes, each 100px wide (no margins).
  9. 9.📱 The screen is 320px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 16px;
      }
    }
    (a) Yes (b) No
  10. 10.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 360px;
      justify-content: flex-start;
    }
    Inside are 4 boxes, each 80px wide (no margins).
  11. 11.🖌️ How big is the text, in px?
    h1 {
      text-align: right;
      background-color: blue;
      font-size: 20px;
      color: orange;
    }
  12. 12.True or false: JavaScript changes the page live. (a) False (b) True
  13. 13.🖌️ What colour is behind the letters?
    h2 {
      background-color: yellow;
      text-align: left;
      color: white;
      font-size: 20px;
    }
    (a) white (b) yellow (c) green
  14. 14.🌈 Which hex code is white? (a) #0000ff (b) #ff00ff (c) #ff0000 (d) #ffffff
  15. 15.✍️ Which property is set to italic in this rule?
    h1 {
      color: red;
      font-style: italic;
      text-align: center;
      margin: 10px;
    }
    (a) font-size (b) italic (c) font-style (d) color
  16. 16.🎯 Which element does the selector li style? (a) <p id="end"> (b) <li class="red"> (c) <div> (d) <span class="red">
  17. 17.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 30px;
      }
    }
  18. 18.✍️ How does a CSS comment start? (a) # (b) // (c) /* (d) <!--
  19. 19.True or false: the border is the gap round content. (a) True (b) False
  20. 20.🔍 Which is the odd one out? (a) changes the text size (b) puts a picture on a page (c) makes a form box (d) gives the page structure
  21. 21.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 230px;
      padding: 5px;
      border: 4px solid black;
      margin: 15px;
    }
  22. 22.📦 In the box model, which part is the gap round content? (a) margin (b) border (c) padding (d) content
  23. 23.🖌️ Which CSS property sets the letter colour? (a) font-size (b) color (c) font-weight (d) text-align
  24. 24.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 130px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 50px wide (no margins).
  25. 25.⚖️ What colour is the text of this element?
    <h1 class="box" id="top">Hi</h1>
    CSS:
    .box { color: black; }
    #top { color: red; }
    h1 { color: orange; }
    (a) orange (b) black (c) red (d) white
  26. 26.✍️ What is the selector in this CSS rule?
    #top {
      font-weight: bold;
      padding: 8px;
      color: red;
      text-align: center;
    }
    (a) 8px (b) font-weight (c) li (d) #top
  27. 27.🎯 Which sign starts a class selector? (a) . (b) @ (c) # (d) &
  28. 28.✍️ What is the selector in this CSS rule?
    .box {
      text-align: center;
      background-color: yellow;
    }
    (a) text-align (b) yellow (c) h2 (d) .box
  29. 29.🧩 Which language makes headings and lists? (a) CSS (b) JavaScript (c) HTML
  30. 30.Which of these does HTML do? (a) changes the text size (b) makes a link (c) adds space around boxes (d) counts down a timer
  31. 31.🖌️ How big is the text, in px?
    h2 {
      color: orange;
      font-size: 16px;
      text-align: right;
      background-color: green;
    }
  32. 32.What does color do? (a) makes the text bold (b) picks the font style (c) sets the letter colour (d) colours behind the text
  33. 33.True or false: margin is space inside the border. (a) False (b) True
  34. 34.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 70px;
      padding: 20px;
      border: 1px solid black;
      margin: 15px;
    }
  35. 35.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 10px;
      }
    }
  36. 36.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) blue (c) white (d) red
  37. 37.💪 Which flexbox property spaces boxes along a row? (a) flex-direction (b) align-items (c) gap (d) justify-content
  38. 38.🎯 Which CSS selector matches this element?
    <li class="red" id="hero">Hello</li>
    (a) li (b) .box (c) .hero (d) #red
  39. 39.🖌️ What colour are the letters?
    p {
      background-color: purple;
      font-size: 36px;
      color: blue;
      text-align: left;
    }
    (a) purple (b) white (c) blue
  40. 40.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 120px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 50px wide (no margins).

Answer key

  1. on the left
  2. 8
  3. :
  4. HTML
  5. black
  6. body
  7. { }
  8. 60
  9. No
  10. 40
  11. 20
  12. True
  13. yellow
  14. #ffffff
  15. font-style
  16. <li class="red">
  17. 24
  18. /*
  19. False
  20. changes the text size
  21. 248
  22. padding
  23. color
  24. 30
  25. red
  26. #top
  27. .
  28. .box
  29. HTML
  30. makes a link
  31. 16
  32. sets the letter colour
  33. False
  34. 142
  35. 10
  36. blue
  37. justify-content
  38. li
  39. blue
  40. 20

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