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

Answer key

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

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