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

Answer key

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

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