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

Answer key

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

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