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

Answer key

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

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