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

Answer key

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

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