← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 371 · 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.✍️ What is the selector in this CSS rule?
    h2 {
      text-align: center;
      font-style: italic;
      border: 2px solid;
    }
    (a) h1 (b) italic (c) h2 (d) text-align
  2. 2.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 230px;
      justify-content: space-between;
    }
    Inside are 4 boxes, each 50px wide (no margins).
  3. 3.💪 Which justify-content value equal gaps, none at ends? (a) flex-start (b) center (c) flex-end (d) space-between
  4. 4.🔍 Which is the odd one out? (a) makes a link (b) makes a form box (c) reacts to a button click (d) gives the page structure
  5. 5.⚖️ What colour is the text of this element?
    <h2 class="star" id="end">Hi</h2>
    CSS:
    .star { color: red; }
    #end { color: orange; }
    (a) orange (b) red (c) white (d) blue
  6. 6.🎯 What kind of selector is #main? (a) a class selector (b) an id selector (c) an element selector
  7. 7.✍️ Which property is set to bold in this rule?
    .box {
      border: 2px solid;
      font-weight: bold;
      margin: 10px;
    }
    (a) bold (b) border (c) width (d) font-weight
  8. 8.🎯 Which element does the selector p style? (a) <h2 class="red"> (b) <p class="red"> (c) <h1> (d) <li id="logo">
  9. 9.✍️ In color: blue; which part is the property? (a) blue (b) : (c) ; (d) color
  10. 10.✍️ Which sign ends each CSS declaration? (a) . (b) , (c) : (d) ;
  11. 11.🎯 Which sign starts an id selector? (a) & (b) # (c) . (d) @
  12. 12.✍️ How does a CSS comment start? (a) // (b) /* (c) <!-- (d) #
  13. 13.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 18px;
      }
    }
  14. 14.🔍 Which is the odd one out? (a) gives the page structure (b) sets colours and fonts (c) makes headings and lists (d) puts a picture on a page
  15. 15.📦 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: 0px;
    }
  16. 16.⚖️ What colour is the text of this element?
    <p class="red" id="hero">Hi</p>
    CSS:
    p { color: purple; }
    #hero { color: black; }
    (a) black (b) blue (c) purple (d) green
  17. 17.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      text-align: center;
      font-style: italic;
      font-size: 20px;
      width: 300px;
    }
  18. 18.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 280px;
      justify-content: center;
    }
    Inside are 3 boxes, each 60px wide (no margins).
  19. 19.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      border: 2px solid;
      margin: 10px;
      font-style: italic;
    }
  20. 20.🌈 Which colour is rgb(0, 0, 255)? (a) bright green (b) cyan (c) yellow (d) blue
  21. 21.Which of these is padding? (a) a solid or dotted edge (b) the gap to other boxes (c) space inside the border (d) the line round the box
  22. 22.🖌️ Where does the text sit on its line?
    li {
      text-align: center;
      background-color: yellow;
      font-size: 12px;
      color: red;
    }
    (a) on the left (b) in the middle (c) on the right
  23. 23.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      font-weight: bold;
    }
  24. 24.What does font-family do? (a) sets the letter colour (b) colours behind the text (c) picks the font style (d) makes the text bold
  25. 25.⚖️ What colour is the text of this element?
    <h1 class="big" id="end">Hi</h1>
    CSS:
    .big { color: purple; }
    h1 { color: blue; }
    #end { color: black; }
    (a) yellow (b) blue (c) purple (d) black
  26. 26.🎯 Which CSS selector matches this element?
    <li class="star" id="logo">Hello</li>
    (a) #end (b) .menu (c) .logo (d) li
  27. 27.🌈 Which colour of light is strongest in rgb(77, 229, 77)? (a) blue (b) green (c) red
  28. 28.True or false: HTML makes a link. (a) False (b) True
  29. 29.🎨 Which tag holds CSS inside the head? (a) <script> (b) <css> (c) <body> (d) <style>
  30. 30.What does justify-content: space-between do? (a) packs boxes at the start (b) packs boxes at the end (c) puts boxes in the middle (d) equal gaps, none at ends
  31. 31.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 220px;
      justify-content: flex-end;
    }
    Inside are 2 boxes, each 100px wide (no margins).
  32. 32.📱 The screen is 375px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 6px;
      }
    }
    (a) Yes (b) No
  33. 33.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 110px;
      padding: 10px;
      border: 1px solid black;
      margin: 5px;
    }
  34. 34.🌈 Which colour is rgb(255, 0, 0)? (a) yellow (b) blue (c) red (d) cyan
  35. 35.⚖️ What colour is the text of this element?
    <h2 class="menu" id="top">Hi</h2>
    CSS:
    h2 { color: white; }
    h2 { color: black; }
    (a) white (b) blue (c) orange (d) black
  36. 36.✍️ Which property is set to yellow in this rule?
    h2 {
      background-color: yellow;
      text-align: center;
      font-weight: bold;
    }
    (a) margin (b) padding (c) background-color (d) yellow
  37. 37.🖌️ How big is the text, in px?
    h2 {
      font-size: 36px;
      color: black;
      background-color: red;
      text-align: left;
    }
  38. 38.True or false: .big is an id selector. (a) False (b) True
  39. 39.🖌️ Which CSS property colours behind the text? (a) color (b) text-align (c) background-color (d) font-family
  40. 40.🧩 Which language checks a quiz answer? (a) HTML (b) CSS (c) JavaScript

Answer key

  1. h2
  2. 10
  3. space-between
  4. reacts to a button click
  5. orange
  6. an id selector
  7. font-weight
  8. <p class="red">
  9. color
  10. ;
  11. #
  12. /*
  13. 18
  14. sets colours and fonts
  15. 134
  16. black
  17. 4
  18. 50
  19. 3
  20. blue
  21. space inside the border
  22. in the middle
  23. 1
  24. picks the font style
  25. black
  26. li
  27. green
  28. True
  29. <style>
  30. equal gaps, none at ends
  31. 20
  32. Yes
  33. 132
  34. red
  35. black
  36. background-color
  37. 36
  38. False
  39. background-color
  40. JavaScript

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