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

Answer key

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

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