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

Answer key

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

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