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

Answer key

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

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