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

Answer key

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

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