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

Answer key

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

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