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

Answer key

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

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