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

Answer key

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

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