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

Answer key

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

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