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

Answer key

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

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