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

Answer key

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

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