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

Answer key

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

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