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

Answer key

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

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