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

Answer key

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

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