← CSS rules: selector, property, value lesson New set →

CSS Worksheet: CSS Rules and Syntax

HTML and CSS lesson 12: CSS rules: selector, property, value · Set 350 · 40 questions
TalentJR

Code tip (Colon in the middle, semicolon at the end): A rule is: selector { property: value; property: value; } The property is before the colon, the value after it; a semicolon ends each declaration. Count the property: value; lines to count the declarations.

NameDateTime takenScore ___ / 40
  1. 1.✍️ What value is given to padding in this rule?
    li {
      font-weight: bold;
      padding: 8px;
      font-size: 20px;
    }
    (a) padding (b) 8px (c) bold (d) 2px solid
  2. 2.✍️ Which sign ends each CSS declaration? (a) , (b) ; (c) . (d) :
  3. 3.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      margin: 10px;
      font-weight: bold;
      border: 2px solid;
    }
  4. 4.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      margin: 10px;
      font-style: italic;
      font-size: 20px;
      padding: 8px;
    }
  5. 5.✍️ Which sign goes between a property and its value? (a) - (b) ; (c) : (d) =
  6. 6.✍️ How does a CSS comment start? (a) <!-- (b) /* (c) // (d) #
  7. 7.✍️ What value is given to background-color in this rule?
    body {
      background-color: yellow;
      color: red;
      font-style: italic;
    }
    (a) background-color (b) yellow (c) 10px (d) 8px
  8. 8.✍️ Which property is set to 2px solid in this rule?
    .box {
      margin: 10px;
      border: 2px solid;
      width: 300px;
    }
    (a) font-style (b) width (c) 2px solid (d) border
  9. 9.✍️ What is the selector in this CSS rule?
    p {
      text-align: center;
      padding: 8px;
      color: red;
    }
    (a) text-align (b) 8px (c) .note (d) p
  10. 10.✍️ What value is given to color in this rule?
    .note {
      font-weight: bold;
      color: red;
      border: 2px solid;
    }
    (a) red (b) 20px (c) color (d) center
  11. 11.✍️ What is the selector in this CSS rule?
    .note {
      padding: 8px;
      border: 2px solid;
      width: 300px;
      margin: 10px;
    }
    (a) padding (b) .note (c) 2px solid (d) #top
  12. 12.✍️ What is the selector in this CSS rule?
    h1 {
      padding: 8px;
      border: 2px solid;
      width: 300px;
    }
    (a) h1 (b) 2px solid (c) padding (d) p
  13. 13.✍️ What value is given to padding in this rule?
    h2 {
      margin: 10px;
      background-color: yellow;
      width: 300px;
      padding: 8px;
    }
    (a) 8px (b) bold (c) padding (d) 2px solid
  14. 14.✍️ In color: blue; which part is the property? (a) blue (b) ; (c) color (d) :
  15. 15.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      padding: 8px;
      background-color: yellow;
      font-style: italic;
    }
  16. 16.✍️ What is the selector in this CSS rule?
    .note {
      font-style: italic;
      width: 300px;
      color: red;
      padding: 8px;
    }
    (a) .note (b) #top (c) font-style (d) 300px
  17. 17.✍️ CSS declarations go inside which brackets? (a) ( ) (b) [ ] (c) < > (d) { }
  18. 18.✍️ Which property is set to italic in this rule?
    li {
      font-size: 20px;
      font-style: italic;
    }
    (a) font-style (b) color (c) italic (d) font-size
  19. 19.✍️ Which property is set to center in this rule?
    h1 {
      color: red;
      text-align: center;
    }
    (a) center (b) background-color (c) margin (d) text-align
  20. 20.✍️ What is the selector in this CSS rule?
    .note {
      margin: 10px;
      font-weight: bold;
    }
    (a) bold (b) #top (c) .note (d) margin
  21. 21.✍️ What is the selector in this CSS rule?
    li {
      font-size: 20px;
      background-color: yellow;
      font-style: italic;
      text-align: center;
    }
    (a) font-size (b) body (c) yellow (d) li
  22. 22.✍️ Which property is set to red in this rule?
    li {
      color: red;
      font-weight: bold;
    }
    (a) color (b) font-size (c) red (d) text-align
  23. 23.✍️ Which property is set to italic in this rule?
    .note {
      text-align: center;
      font-style: italic;
      color: red;
      padding: 8px;
    }
    (a) font-style (b) font-size (c) italic (d) color
  24. 24.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      color: red;
      margin: 10px;
      font-size: 20px;
    }
  25. 25.✍️ What value is given to width in this rule?
    .box {
      width: 300px;
      text-align: center;
      color: red;
      font-size: 20px;
    }
    (a) red (b) italic (c) width (d) 300px
  26. 26.✍️ What is the selector in this CSS rule?
    .note {
      border: 2px solid;
      width: 300px;
    }
    (a) 300px (b) #top (c) .note (d) border
  27. 27.✍️ What is the selector in this CSS rule?
    p {
      margin: 10px;
      font-size: 20px;
      text-align: center;
      color: red;
    }
    (a) .note (b) margin (c) 20px (d) p
  28. 28.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      font-size: 20px;
      text-align: center;
      background-color: yellow;
    }
  29. 29.✍️ What is the selector in this CSS rule?
    .box {
      color: red;
      font-weight: bold;
    }
    (a) color (b) bold (c) .box (d) h2
  30. 30.✍️ Which property is set to yellow in this rule?
    h2 {
      background-color: yellow;
      font-size: 20px;
    }
    (a) padding (b) margin (c) yellow (d) background-color
  31. 31.✍️ What is the selector in this CSS rule?
    h1 {
      color: red;
      border: 2px solid;
      background-color: yellow;
    }
    (a) color (b) h1 (c) p (d) 2px solid
  32. 32.✍️ What value is given to color in this rule?
    p {
      color: red;
      background-color: yellow;
      width: 300px;
      border: 2px solid;
    }
    (a) color (b) red (c) 20px (d) center
  33. 33.✍️ In color: blue; which part is the value? (a) color (b) blue (c) : (d) ;
  34. 34.✍️ What is the selector in this CSS rule?
    body {
      font-size: 20px;
      font-style: italic;
      background-color: yellow;
      margin: 10px;
    }
    (a) .box (b) body (c) font-size (d) italic
  35. 35.✍️ Which property is set to bold in this rule?
    h1 {
      width: 300px;
      font-weight: bold;
    }
    (a) border (b) font-weight (c) bold (d) width
  36. 36.✍️ Which property is set to 8px in this rule?
    .note {
      margin: 10px;
      padding: 8px;
    }
    (a) padding (b) border (c) 8px (d) font-weight
  37. 37.✍️ Which property is set to center in this rule?
    p {
      text-align: center;
      background-color: yellow;
      font-weight: bold;
    }
    (a) margin (b) center (c) background-color (d) text-align
  38. 38.✍️ How many declarations (property: value pairs) are in this rule?
    li {
      text-align: center;
      font-size: 20px;
      color: red;
      font-weight: bold;
    }
  39. 39.✍️ What is the selector in this CSS rule?
    .box {
      text-align: center;
      border: 2px solid;
      margin: 10px;
    }
    (a) text-align (b) 2px solid (c) h2 (d) .box
  40. 40.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      font-style: italic;
      font-size: 20px;
      background-color: yellow;
      font-weight: bold;
    }

Answer key

  1. 8px
  2. ;
  3. 3
  4. 4
  5. :
  6. /*
  7. yellow
  8. border
  9. p
  10. red
  11. .note
  12. h1
  13. 8px
  14. color
  15. 3
  16. .note
  17. { }
  18. font-style
  19. text-align
  20. .note
  21. li
  22. color
  23. font-style
  24. 3
  25. 300px
  26. .note
  27. p
  28. 3
  29. .box
  30. background-color
  31. h1
  32. red
  33. blue
  34. body
  35. font-weight
  36. padding
  37. text-align
  38. 4
  39. .box
  40. 4

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