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

Answer key

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

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