← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 198 · 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.🎯 Which CSS selector matches this element?
    <p class="box" id="main">Hello</p>
    (a) p (b) #box (c) .star (d) .main
  2. 2.📱 min-width: 800px applies when the screen is ___. (a) 800px or wider (b) 800px or narrower (c) turned off (d) exactly 100px
  3. 3.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 18px;
      }
    }
  4. 4.🎯 Which element does the selector #end style? (a) <span id="hero"> (b) <span id="end"> (c) <p class="big"> (d) <span class="end">
  5. 5.⚖️ What colour is the text of this element?
    <p class="menu" id="main">Hi</p>
    CSS:
    .menu { color: black; }
    #main { color: red; }
    (a) purple (b) green (c) black (d) red
  6. 6.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 350px;
      justify-content: flex-end;
    }
    Inside are 4 boxes, each 80px wide (no margins).
  7. 7.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 360px;
      justify-content: center;
    }
    Inside are 3 boxes, each 80px wide (no margins).
  8. 8.🔍 Which is the odd one out? (a) puts a picture on a page (b) makes a link (c) changes the page live (d) gives the page structure
  9. 9.🌈 In #0000f8 the blue part is the hex number f8. What is it as a normal number?
  10. 10.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 400px;
      justify-content: center;
    }
    Inside are 3 boxes, each 80px wide (no margins).
  11. 11.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 140px;
      padding: 30px;
      border: 1px solid black;
      margin: 10px;
    }
  12. 12.📦 In the box model, which part is the text or picture? (a) padding (b) margin (c) border (d) content
  13. 13.⚖️ What colour is the text of this element?
    <h2 class="box" id="top">Hi</h2>
    CSS:
    h2 { color: green; }
    h2 { color: red; }
    (a) red (b) green (c) orange (d) black
  14. 14.True or false: the content is the line round the box. (a) True (b) False
  15. 15.✍️ What is the selector in this CSS rule?
    h1 {
      width: 300px;
      border: 2px solid;
      font-weight: bold;
      font-style: italic;
    }
    (a) width (b) 2px solid (c) p (d) h1
  16. 16.⚖️ What colour is the text of this element?
    <h2 class="note" id="top">Hi</h2>
    CSS:
    .note { color: red; }
    h2 { color: green; }
    (a) orange (b) green (c) red (d) yellow
  17. 17.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 390px;
      justify-content: flex-start;
    }
    Inside are 4 boxes, each 80px wide (no margins).
  18. 18.🎯 Which element does the selector div style? (a) <span> (b) <div class="red"> (c) <p class="red"> (d) <h1 id="intro">
  19. 19.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 10px;
      }
    }
  20. 20.🔍 Which is the odd one out? (a) makes a form box (b) counts down a timer (c) changes the page live (d) reacts to a button click
  21. 21.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 240px;
      justify-content: flex-start;
    }
    Inside are 4 boxes, each 50px wide (no margins).
  22. 22.📱 The screen is 540px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 16px;
      }
    }
    (a) No (b) Yes
  23. 23.✍️ What is the selector in this CSS rule?
    #top {
      font-style: italic;
      color: red;
      background-color: yellow;
    }
    (a) li (b) #top (c) red (d) font-style
  24. 24.🖌️ Where does the text sit on its line?
    h1 {
      text-align: left;
      background-color: orange;
      font-size: 40px;
      color: blue;
    }
    (a) on the right (b) on the left (c) in the middle
  25. 25.🌈 Which colour is #00ff00? (a) bright green (b) white (c) red (d) yellow
  26. 26.🖌️ What colour is behind the letters?
    li {
      font-size: 24px;
      background-color: white;
      color: black;
      text-align: right;
    }
    (a) purple (b) black (c) white
  27. 27.🎯 How many elements on a page should have the same id? (a) 2 (b) any number (c) 5 (d) 1
  28. 28.🔍 Which is the odd one out? (a) makes a link (b) makes headings and lists (c) gives the page structure (d) shows a pop-up message
  29. 29.📦 In the box model, which part is the line round the box? (a) border (b) padding (c) content (d) margin
  30. 30.💪 Which flexbox property lines boxes up across? (a) flex-direction (b) gap (c) display: flex (d) align-items
  31. 31.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 190px;
      justify-content: flex-start;
    }
    Inside are 3 boxes, each 50px wide (no margins).
  32. 32.True or false: #hero is an id selector. (a) False (b) True
  33. 33.What does font-size do? (a) sets the letter colour (b) makes letters bigger (c) colours behind the text (d) picks the font style
  34. 34.🎯 Can many elements share the same class? (a) No (b) Yes
  35. 35.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 22px;
      }
    }
  36. 36.True or false: JavaScript gives the page structure. (a) False (b) True
  37. 37.📱 Which tag helps phones show a page at the right size? (a) the br tag (b) the title tag (c) the hr tag (d) the viewport meta tag
  38. 38.🌈 In #rrggbb, which colour do the last two digits give? (a) red (b) white (c) blue (d) green
  39. 39.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 200px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 60px wide (no margins).
  40. 40.🎯 Which CSS selector matches this element?
    <li class="note" id="end">Hello</li>
    (a) .big (b) .note (c) #hero (d) div

Answer key

  1. p
  2. 800px or wider
  3. 18
  4. <span id="end">
  5. red
  6. 30
  7. 60
  8. changes the page live
  9. 248
  10. 80
  11. 222
  12. content
  13. red
  14. False
  15. h1
  16. red
  17. 70
  18. <div class="red">
  19. 10
  20. makes a form box
  21. 40
  22. No
  23. #top
  24. on the left
  25. bright green
  26. white
  27. 1
  28. shows a pop-up message
  29. border
  30. align-items
  31. 40
  32. True
  33. makes letters bigger
  34. Yes
  35. 20
  36. False
  37. the viewport meta tag
  38. blue
  39. 80
  40. .note

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