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

Answer key

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

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