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

Answer key

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

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