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

Answer key

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

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