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

Answer key

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

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