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

Answer key

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

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