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

Answer key

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

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