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

Answer key

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

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