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

Answer key

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

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