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

Answer key

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

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