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

Answer key

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

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