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

Answer key

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

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