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

Answer key

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

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