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

Answer key

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

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