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

Answer key

  1. width
  2. 20px
  3. :
  4. 2
  5. color
  6. 1
  7. blue
  8. background-color
  9. 300px
  10. italic
  11. 3
  12. 2
  13. text-align
  14. 4
  15. ;
  16. center
  17. border
  18. yellow
  19. 2
  20. { }
  21. 2
  22. 3
  23. color
  24. 3
  25. .box
  26. 4
  27. 4
  28. .box
  29. 300px
  30. /*
  31. #top
  32. 1
  33. width
  34. 4
  35. yellow
  36. 3
  37. .box
  38. body
  39. #top
  40. padding

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