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

Answer key

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

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