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

Answer key

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

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