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

Answer key

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

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