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

Answer key

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

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