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

Answer key

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

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