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

Answer key

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

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