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

Answer key

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

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