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

Answer key

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

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