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

Answer key

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

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