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

Answer key

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

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