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

Answer key

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

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