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

Answer key

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

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