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

Answer key

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

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