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

Answer key

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

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