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

Answer key

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

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