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

Answer key

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

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