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

Answer key

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

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