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

Answer key

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

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