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

Answer key

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

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