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

Answer key

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

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