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

Answer key

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

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