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

Answer key

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

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