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

Answer key

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

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