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

Answer key

  1. :
  2. blue
  3. 4
  4. h2
  5. { }
  6. 4
  7. 1
  8. p
  9. 8px
  10. italic
  11. 2
  12. 3
  13. body
  14. 1
  15. ;
  16. 3
  17. color
  18. 3
  19. background-color
  20. p
  21. width
  22. .note
  23. 10px
  24. 3
  25. 2
  26. p
  27. 1
  28. red
  29. 2
  30. 2
  31. color
  32. li
  33. 2
  34. h1
  35. 1
  36. margin
  37. padding
  38. 1
  39. 2
  40. width

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