← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 615 · 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 {
      font-size: 28px;
      background-color: red;
      color: black;
      text-align: left;
    }
    (a) on the right (b) on the left (c) in the middle
  2. 2.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      text-align: center;
      color: red;
      border: 2px solid;
      font-weight: bold;
    }
  3. 3.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 140px;
      justify-content: flex-end;
    }
    Inside are 2 boxes, each 60px wide (no margins).
  4. 4.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      padding: 8px;
    }
  5. 5.🎯 Which CSS selector matches this element?
    <p class="menu" id="top">Hello</p>
    (a) #intro (b) h1 (c) #menu (d) #top
  6. 6.✍️ Which property is set to red in this rule?
    li {
      color: red;
      width: 300px;
    }
    (a) text-align (b) red (c) color (d) font-size
  7. 7.🌈 Which colour is #000000? (a) black (b) red (c) cyan (d) yellow
  8. 8.📦 In the box model, which part is the line round the box? (a) border (b) content (c) margin (d) padding
  9. 9.💪 Which justify-content value packs boxes at the end? (a) space-between (b) flex-end (c) center (d) flex-start
  10. 10.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 410px;
      justify-content: space-between;
    }
    Inside are 4 boxes, each 80px wide (no margins).
  11. 11.📱 The screen is 540px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 14px;
      }
    }
    (a) No (b) Yes
  12. 12.🖌️ What colour are the letters?
    h1 {
      background-color: yellow;
      font-size: 28px;
      text-align: left;
      color: blue;
    }
    (a) yellow (b) blue (c) black
  13. 13.🖌️ What colour is behind the letters?
    li {
      background-color: white;
      font-size: 28px;
      color: purple;
      text-align: right;
    }
    (a) white (b) green (c) purple
  14. 14.Which of these is padding? (a) a solid or dotted edge (b) space inside the border (c) space outside the border (d) the text or picture
  15. 15.🧩 Which language makes headings and lists? (a) CSS (b) HTML (c) JavaScript
  16. 16.🎯 What kind of selector is .menu? (a) an id selector (b) a class selector (c) an element selector
  17. 17.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 32px;
      }
    }
  18. 18.True or false: #main is a class selector. (a) True (b) False
  19. 19.🎨 Which attribute adds CSS inside one tag? (a) src (b) href (c) alt (d) style
  20. 20.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 490px;
      justify-content: space-between;
    }
    Inside are 4 boxes, each 100px wide (no margins).
  21. 21.⚖️ What colour is the text of this element?
    <h2 class="red" id="intro">Hi</h2>
    CSS:
    h2 { color: green; }
    h2 { color: blue; }
    (a) white (b) blue (c) green (d) orange
  22. 22.What does text-align do? (a) makes letters bigger (b) sets the letter colour (c) centres a heading (d) makes the text bold
  23. 23.🎯 Which CSS selector matches this element?
    <li class="big" id="main">Hello</li>
    (a) #logo (b) li (c) .main (d) .red
  24. 24.🔍 Which is the odd one out? (a) rounds box corners (b) makes a form box (c) makes headings and lists (d) makes a link
  25. 25.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 110px;
      padding: 25px;
      border: 5px solid black;
      margin: 5px;
    }
  26. 26.True or false: margin is the gap round content. (a) True (b) False
  27. 27.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 170px;
      justify-content: flex-end;
    }
    Inside are 2 boxes, each 80px wide (no margins).
  28. 28.✍️ What is the selector in this CSS rule?
    #top {
      text-align: center;
      margin: 10px;
      color: red;
    }
    (a) #top (b) li (c) 10px (d) text-align
  29. 29.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) turned off (c) 800px or wider (d) exactly 100px
  30. 30.📱 What does a media query check? (a) the time of day (b) the screen width (c) the battery level (d) the page title
  31. 31.📱 The screen is 1100px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 32px;
      }
    }
    (a) No (b) Yes
  32. 32.✍️ What value is given to color in this rule?
    p {
      text-align: center;
      color: red;
    }
    (a) color (b) 20px (c) red (d) center
  33. 33.What does font-family do? (a) colours behind the text (b) picks the font style (c) makes letters bigger (d) sets the letter colour
  34. 34.🎯 What kind of selector is .card? (a) an element selector (b) a class selector (c) an id selector
  35. 35.True or false: HTML reacts to a button click. (a) True (b) False
  36. 36.✍️ Which sign goes between a property and its value? (a) ; (b) - (c) : (d) =
  37. 37.🎯 Which element does the selector .star style? (a) <li id="star"> (b) <div class="note"> (c) <li class="star"> (d) <li class="menu">
  38. 38.What does font-size do? (a) colours behind the text (b) makes letters bigger (c) makes the text bold (d) sets the letter colour
  39. 39.True or false: #logo is an id selector. (a) False (b) True
  40. 40.✍️ Which property is set to red in this rule?
    h1 {
      color: red;
      background-color: yellow;
    }
    (a) red (b) text-align (c) color (d) font-size

Answer key

  1. on the left
  2. 4
  3. 20
  4. 1
  5. #top
  6. color
  7. black
  8. border
  9. flex-end
  10. 30
  11. Yes
  12. blue
  13. white
  14. space inside the border
  15. HTML
  16. a class selector
  17. 32
  18. False
  19. style
  20. 30
  21. blue
  22. centres a heading
  23. li
  24. rounds box corners
  25. 180
  26. False
  27. 10
  28. #top
  29. 800px or wider
  30. the screen width
  31. Yes
  32. red
  33. picks the font style
  34. a class selector
  35. False
  36. :
  37. <li class="star">
  38. makes letters bigger
  39. True
  40. color

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