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

Answer key

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

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