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

Answer key

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

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