← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 62 · 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 is the odd one out? (a) shows a pop-up message (b) changes the page live (c) counts down a timer (d) puts a picture on a page
  2. 2.🌈 Which colour is #000000? (a) yellow (b) black (c) blue (d) red
  3. 3.✍️ What value is given to padding in this rule?
    .note {
      padding: 8px;
      background-color: yellow;
    }
    (a) bold (b) 2px solid (c) padding (d) 8px
  4. 4.🖌️ Where does the text sit on its line?
    li {
      text-align: right;
      background-color: yellow;
      font-size: 12px;
      color: white;
    }
    (a) on the left (b) in the middle (c) on the right
  5. 5.🎯 Which element does the selector h2 style? (a) <h2 class="big"> (b) <li> (c) <div class="big"> (d) <span id="main">
  6. 6.💪 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 60px wide (no margins).
  7. 7.📱 The screen is 320px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 16px;
      }
    }
    (a) No (b) Yes
  8. 8.🎯 Which element does the selector .star style? (a) <h2 class="note"> (b) <h1 class="star"> (c) <h1 id="star"> (d) <h1 class="menu">
  9. 9.Which of these is the content? (a) space inside the border (b) the text or picture (c) the gap to other boxes (d) the line round the box
  10. 10.🔍 Which is the odd one out? (a) rounds box corners (b) shows a pop-up message (c) lays out the page (d) sets colours and fonts
  11. 11.💪 Which flexbox property lines boxes up across? (a) display: flex (b) justify-content (c) align-items (d) gap
  12. 12.Which of these does JavaScript do? (a) makes headings and lists (b) puts a picture on a page (c) makes a form box (d) shows a pop-up message
  13. 13.📦 In the box model, which part is a solid or dotted edge? (a) border (b) content (c) margin (d) padding
  14. 14.🎯 Which element does the selector span style? (a) <p> (b) <h2 id="intro"> (c) <span class="red"> (d) <h1 class="red">
  15. 15.🔍 Which is the odd one out? (a) adds space around boxes (b) checks a quiz answer (c) changes the text size (d) rounds box corners
  16. 16.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 16px;
      }
    }
  17. 17.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) 600px or narrower (c) turned off (d) exactly 1000px
  18. 18.🎨 Which attribute adds CSS inside one tag? (a) alt (b) src (c) style (d) href
  19. 19.✍️ Which property is set to yellow in this rule?
    h2 {
      background-color: yellow;
      margin: 10px;
      color: red;
    }
    (a) yellow (b) background-color (c) padding (d) margin
  20. 20.⚖️ What colour is the text of this element?
    <h2 class="star" id="logo">Hi</h2>
    CSS:
    #logo { color: purple; }
    h2 { color: white; }
    .star { color: blue; }
    (a) white (b) purple (c) orange (d) blue
  21. 21.🎯 Which sign starts an id selector? (a) & (b) # (c) @ (d) .
  22. 22.🧩 Which language sets colours and fonts? (a) HTML (b) CSS (c) JavaScript
  23. 23.🖌️ What colour are the letters?
    p {
      text-align: left;
      background-color: orange;
      color: white;
      font-size: 28px;
    }
    (a) orange (b) red (c) white
  24. 24.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 28px;
      }
    }
  25. 25.True or false: CSS shows a pop-up message. (a) False (b) True
  26. 26.🌈 Which colour is #00ff00? (a) blue (b) black (c) bright green (d) magenta
  27. 27.🎨 A CSS file usually ends with which extension? (a) .js (b) .png (c) .css (d) .html
  28. 28.⚖️ Which selector is the weakest? (a) an id selector (b) an element selector (c) a class selector
  29. 29.⚖️ What colour is the text of this element?
    <p class="note" id="intro">Hi</p>
    CSS:
    #intro { color: black; }
    #intro { color: yellow; }
    (a) purple (b) black (c) blue (d) yellow
  30. 30.🎯 How many elements on a page should have the same id? (a) 5 (b) 1 (c) any number (d) 2
  31. 31.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 110px;
      padding: 10px;
      border: 2px solid black;
      margin: 10px;
    }
  32. 32.✍️ What value is given to font-size in this rule?
    h1 {
      margin: 10px;
      text-align: center;
      font-size: 20px;
    }
    (a) 20px (b) center (c) font-size (d) yellow
  33. 33.🎯 Which element does the selector .red style? (a) <h2 id="red"> (b) <li class="star"> (c) <h2 class="box"> (d) <h2 class="red">
  34. 34.⚖️ What colour is the text of this element?
    <p class="red" id="main">Hi</p>
    CSS:
    #main { color: red; }
    #main { color: yellow; }
    (a) red (b) white (c) green (d) yellow
  35. 35.🌈 Hex digits go 0 to 9, then A to which letter? (a) G (b) Z (c) J (d) F
  36. 36.What does font-family do? (a) makes letters bigger (b) sets the letter colour (c) makes the text bold (d) picks the font style
  37. 37.Which of these is margin? (a) a solid or dotted edge (b) the text or picture (c) space outside the border (d) the line round the box
  38. 38.🎯 What kind of selector is p? (a) an id selector (b) an element selector (c) a class selector
  39. 39.🧩 Which language counts down a timer? (a) CSS (b) JavaScript (c) HTML
  40. 40.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 16px;
      }
    }

Answer key

  1. puts a picture on a page
  2. black
  3. 8px
  4. on the right
  5. <h2 class="big">
  6. 60
  7. No
  8. <h1 class="star">
  9. the text or picture
  10. shows a pop-up message
  11. align-items
  12. shows a pop-up message
  13. border
  14. <span class="red">
  15. checks a quiz answer
  16. 20
  17. 600px or narrower
  18. style
  19. background-color
  20. purple
  21. #
  22. CSS
  23. white
  24. 24
  25. False
  26. bright green
  27. .css
  28. an element selector
  29. yellow
  30. 1
  31. 154
  32. 20px
  33. <h2 class="red">
  34. yellow
  35. F
  36. picks the font style
  37. space outside the border
  38. an element selector
  39. JavaScript
  40. 16

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