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

Answer key

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

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