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

Answer key

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

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