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

Answer key

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

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