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

Answer key

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

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