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

Answer key

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

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