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

Answer key

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

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