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

Answer key

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

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