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

Answer key

  1. color
  2. color
  3. li
  4. /*
  5. blue
  6. 1
  7. 8px
  8. .box
  9. 10px
  10. 1
  11. ;
  12. 3
  13. font-size
  14. 4
  15. body
  16. color
  17. 1
  18. color
  19. 4
  20. h2
  21. red
  22. margin
  23. h2
  24. 1
  25. .box
  26. font-style
  27. border
  28. bold
  29. width
  30. 1
  31. background-color
  32. 1
  33. 4
  34. color
  35. 2
  36. p
  37. 4
  38. margin
  39. border
  40. li

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