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

Answer key

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

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