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

Answer key

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

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