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

Answer key

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

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