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

Answer key

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

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