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

Answer key

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

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