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

Answer key

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

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