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

Answer key

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

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