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

Answer key

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

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