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

Answer key

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

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