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

Answer key

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

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