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

Answer key

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

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