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

Answer key

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

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