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

Answer key

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

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