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

Answer key

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

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