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

Answer key

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

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