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

Answer key

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

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