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

Answer key

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

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