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

Answer key

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

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