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

Answer key

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

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