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

Answer key

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

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