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

Answer key

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

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