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

Answer key

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

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