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

Answer key

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

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