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

Answer key

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

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