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

Answer key

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

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