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

Answer key

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

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