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

Answer key

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

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