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

Answer key

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

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