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

Answer key

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

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