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

Answer key

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

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