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

Answer key

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

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