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

Answer key

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

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