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

Answer key

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

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