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

Answer key

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

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