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

Answer key

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

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