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

Answer key

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

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