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

Answer key

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

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