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

Answer key

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

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