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

Answer key

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

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