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

Answer key

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

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