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

Answer key

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

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