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

Answer key

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

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