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

Answer key

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

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