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

Answer key

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

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