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

Answer key

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

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