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

Answer key

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

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