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

Answer key

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

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