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

Answer key

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

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