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

Answer key

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

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