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

Answer key

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

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