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

Answer key

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

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