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

Answer key

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

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