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

Answer key

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

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