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

Answer key

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

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