← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 65 · 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 375px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 22px;
      }
    }
    (a) No (b) Yes
  2. 2.📦 In the box model, which part is space inside the border? (a) border (b) margin (c) content (d) padding
  3. 3.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 190px;
      padding: 5px;
      border: 2px solid black;
      margin: 5px;
    }
  4. 4.✍️ What is the selector in this CSS rule?
    .note {
      color: red;
      font-weight: bold;
      margin: 10px;
    }
    (a) bold (b) .note (c) color (d) #top
  5. 5.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 6px;
      }
    }
    (a) No (b) Yes
  6. 6.True or false: li is an element selector. (a) False (b) True
  7. 7.📱 What does a media query check? (a) the page title (b) the battery level (c) the time of day (d) the screen width
  8. 8.✍️ What is the selector in this CSS rule?
    p {
      background-color: yellow;
      margin: 10px;
      font-weight: bold;
    }
    (a) p (b) background-color (c) 10px (d) .note
  9. 9.🌈 What is the biggest number one colour can have in rgb()? (a) 100 (b) 255 (c) 99 (d) 1000
  10. 10.✍️ Which sign ends each CSS declaration? (a) ; (b) : (c) . (d) ,
  11. 11.✍️ What value is given to font-size in this rule?
    .box {
      margin: 10px;
      font-size: 20px;
      border: 2px solid;
      width: 300px;
    }
    (a) yellow (b) font-size (c) 20px (d) center
  12. 12.🌈 Which colour is rgb(255, 0, 0)? (a) cyan (b) bright green (c) yellow (d) red
  13. 13.✍️ In color: blue; which part is the value? (a) : (b) color (c) blue (d) ;
  14. 14.What does background-color do? (a) makes the text bold (b) makes letters bigger (c) colours behind the text (d) picks the font style
  15. 15.What does justify-content: center do? (a) equal gaps, none at ends (b) packs boxes at the end (c) puts boxes in the middle (d) packs boxes at the start
  16. 16.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 16px;
      }
    }
  17. 17.🎨 Which tag connects an outside CSS file? (a) <css> (b) <a> (c) <img> (d) <link>
  18. 18.💪 Which justify-content value packs boxes at the start? (a) flex-end (b) space-between (c) center (d) flex-start
  19. 19.🖌️ What colour are the letters?
    h1 {
      text-align: center;
      font-size: 12px;
      color: red;
      background-color: green;
    }
    (a) green (b) red (c) orange
  20. 20.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 140px;
      justify-content: flex-start;
    }
    Inside are 3 boxes, each 40px wide (no margins).
  21. 21.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 120px;
      justify-content: space-between;
    }
    Inside are 2 boxes, each 40px wide (no margins).
  22. 22.🌈 Which colour is #ffffff? (a) blue (b) white (c) red (d) cyan
  23. 23.True or false: JavaScript checks a quiz answer. (a) True (b) False
  24. 24.True or false: #top is an id selector. (a) True (b) False
  25. 25.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
  26. 26.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 180px;
      padding: 15px;
      border: 4px solid black;
      margin: 0px;
    }
  27. 27.🎯 What kind of selector is .note? (a) an element selector (b) an id selector (c) a class selector
  28. 28.⚖️ What colour is the text of this element?
    <h1 class="note" id="intro">Hi</h1>
    CSS:
    h1 { color: orange; }
    .note { color: yellow; }
    #intro { color: white; }
    (a) orange (b) white (c) red (d) yellow
  29. 29.📱 Which tag helps phones show a page at the right size? (a) the title tag (b) the br tag (c) the hr tag (d) the viewport meta tag
  30. 30.🌈 Which hex code is yellow? (a) #ffff00 (b) #ffffff (c) #0000ff (d) #00ff00
  31. 31.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 120px;
      padding: 10px;
      border: 4px solid black;
      margin: 5px;
    }
  32. 32.💪 Which justify-content value packs boxes at the end? (a) space-between (b) center (c) flex-end (d) flex-start
  33. 33.What does justify-content: space-between do? (a) packs boxes at the start (b) puts boxes in the middle (c) equal gaps, none at ends (d) packs boxes at the end
  34. 34.⚖️ What colour is the text of this element?
    <h2 class="note" id="top">Hi</h2>
    CSS:
    .note { color: yellow; }
    .note { color: black; }
    (a) orange (b) yellow (c) black (d) blue
  35. 35.🌈 Which hex code is cyan? (a) #00ff00 (b) #00ffff (c) #0000ff (d) #ff0000
  36. 36.🖌️ Where does the text sit on its line?
    p {
      color: purple;
      background-color: green;
      font-size: 16px;
      text-align: right;
    }
    (a) on the left (b) in the middle (c) on the right
  37. 37.🎯 Which CSS selector matches this element?
    <div class="box" id="top">Hello</div>
    (a) #intro (b) div (c) span (d) .top
  38. 38.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 6px;
      }
    }
  39. 39.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 90px;
      padding: 25px;
      border: 2px solid black;
      margin: 15px;
    }
  40. 40.⚖️ What colour is the text of this element?
    <p class="red" id="main">Hi</p>
    CSS:
    p { color: yellow; }
    #main { color: red; }
    (a) red (b) white (c) blue (d) yellow

Answer key

  1. Yes
  2. padding
  3. 214
  4. .note
  5. Yes
  6. True
  7. the screen width
  8. p
  9. 255
  10. ;
  11. 20px
  12. red
  13. blue
  14. colours behind the text
  15. puts boxes in the middle
  16. 20
  17. <link>
  18. flex-start
  19. red
  20. 20
  21. 40
  22. white
  23. True
  24. True
  25. an id selector
  26. 218
  27. a class selector
  28. white
  29. the viewport meta tag
  30. #ffff00
  31. 148
  32. flex-end
  33. equal gaps, none at ends
  34. black
  35. #00ffff
  36. on the right
  37. div
  38. 6
  39. 174
  40. red

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