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

Answer key

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

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