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

Answer key

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

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