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

Answer key

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

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