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

Answer key

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

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