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

Answer key

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

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