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

Answer key

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

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