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

Answer key

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

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