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

Answer key

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

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