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

Answer key

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

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