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

Answer key

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

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