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

Answer key

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

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