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

Answer key

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

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