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

Answer key

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

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