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

Answer key

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

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