← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 858 · 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 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 20px;
      }
    }
  2. 2.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 90px;
      padding: 10px;
      border: 4px solid black;
      margin: 10px;
    }
  3. 3.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 440px;
      justify-content: center;
    }
    Inside are 3 boxes, each 100px wide (no margins).
  4. 4.🎯 Which sign starts an id selector? (a) . (b) # (c) & (d) @
  5. 5.🎯 Which element does the selector p style? (a) <h1> (b) <p class="menu"> (c) <li id="end"> (d) <h2 class="menu">
  6. 6.🌈 Which colour is #ff0000? (a) cyan (b) yellow (c) red (d) bright green
  7. 7.📱 The screen is 820px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 16px;
      }
    }
    (a) No (b) Yes
  8. 8.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 290px;
      justify-content: space-between;
    }
    Inside are 4 boxes, each 50px wide (no margins).
  9. 9.🖌️ How big is the text, in px?
    p {
      color: blue;
      text-align: left;
      background-color: green;
      font-size: 24px;
    }
  10. 10.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 16px;
      }
    }
  11. 11.🖌️ What colour is behind the letters?
    li {
      background-color: purple;
      text-align: right;
      font-size: 12px;
      color: red;
    }
    (a) red (b) green (c) purple
  12. 12.⚖️ Which selector is the weakest? (a) an element selector (b) an id selector (c) a class selector
  13. 13.What does font-family do? (a) colours behind the text (b) picks the font style (c) sets the letter colour (d) makes the text bold
  14. 14.✍️ Which property is set to 8px in this rule?
    h1 {
      border: 2px solid;
      padding: 8px;
      font-weight: bold;
      text-align: center;
    }
    (a) 8px (b) border (c) padding (d) font-weight
  15. 15.🖌️ Which CSS property picks the font style? (a) font-family (b) font-weight (c) color (d) font-size
  16. 16.🧩 Which language rounds box corners? (a) JavaScript (b) CSS (c) HTML
  17. 17.⚖️ What colour is the text of this element?
    <h1 class="star" id="end">Hi</h1>
    CSS:
    #end { color: black; }
    #end { color: red; }
    (a) green (b) red (c) orange (d) black
  18. 18.✍️ Which property is set to italic in this rule?
    p {
      color: red;
      background-color: yellow;
      font-style: italic;
    }
    (a) font-size (b) font-style (c) italic (d) color
  19. 19.🌈 Which colour of light is strongest in rgb(161, 108, 82)? (a) green (b) red (c) blue
  20. 20.🎯 Which element does the selector h1 style? (a) <h1 class="big"> (b) <li class="big"> (c) <div id="logo"> (d) <h2>
  21. 21.📦 In the box model, which part is space outside the border? (a) padding (b) content (c) border (d) margin
  22. 22.🌈 Which colour is rgb(255, 255, 255)? (a) magenta (b) cyan (c) white (d) yellow
  23. 23.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 10px;
      }
    }
  24. 24.✍️ How does a CSS comment start? (a) # (b) // (c) /* (d) <!--
  25. 25.💪 Which justify-content value equal gaps, none at ends? (a) flex-end (b) center (c) flex-start (d) space-between
  26. 26.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      border: 2px solid;
      color: red;
    }
  27. 27.📦 In the box model, which part is the gap to other boxes? (a) margin (b) content (c) padding (d) border
  28. 28.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 210px;
      justify-content: flex-end;
    }
    Inside are 4 boxes, each 40px wide (no margins).
  29. 29.🧩 Which language adds space around boxes? (a) CSS (b) JavaScript (c) HTML
  30. 30.🌈 Which hex code is yellow? (a) #00ff00 (b) #ff0000 (c) #00ffff (d) #ffff00
  31. 31.✍️ What is the selector in this CSS rule?
    .box {
      font-style: italic;
      font-size: 20px;
      width: 300px;
      text-align: center;
    }
    (a) 20px (b) font-style (c) .box (d) h2
  32. 32.🎯 Which element does the selector #top style? (a) <h2 id="top"> (b) <h2 class="top"> (c) <li class="big"> (d) <h2 id="intro">
  33. 33.🖌️ What colour is behind the letters?
    p {
      font-size: 40px;
      background-color: white;
      text-align: right;
      color: blue;
    }
    (a) blue (b) orange (c) white
  34. 34.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 80px;
      padding: 15px;
      border: 1px solid black;
      margin: 5px;
    }
  35. 35.🖌️ What colour are the letters?
    p {
      color: white;
      text-align: center;
      background-color: black;
      font-size: 40px;
    }
    (a) purple (b) black (c) white
  36. 36.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      color: red;
      text-align: center;
      padding: 8px;
      width: 300px;
    }
  37. 37.🎯 Which CSS selector matches this element?
    <p class="menu" id="main">Hello</p>
    (a) .note (b) .menu (c) .main (d) #menu
  38. 38.⚖️ What colour is the text of this element?
    <p class="menu" id="end">Hi</p>
    CSS:
    #end { color: yellow; }
    p { color: green; }
    (a) purple (b) green (c) white (d) yellow
  39. 39.💪 Which flexbox property turns on flexbox? (a) justify-content (b) display: flex (c) flex-direction (d) align-items
  40. 40.🧩 Which language reacts to a button click? (a) CSS (b) HTML (c) JavaScript

Answer key

  1. 20
  2. 118
  3. 70
  4. #
  5. <p class="menu">
  6. red
  7. Yes
  8. 30
  9. 24
  10. 16
  11. purple
  12. an element selector
  13. picks the font style
  14. padding
  15. font-family
  16. CSS
  17. red
  18. font-style
  19. red
  20. <h1 class="big">
  21. margin
  22. white
  23. 10
  24. /*
  25. space-between
  26. 2
  27. margin
  28. 50
  29. CSS
  30. #ffff00
  31. .box
  32. <h2 id="top">
  33. white
  34. 122
  35. white
  36. 4
  37. .menu
  38. yellow
  39. display: flex
  40. JavaScript

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