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

Answer key

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

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