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

Answer key

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

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