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

Answer key

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

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