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

Answer key

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

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