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

Answer key

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

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