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

Answer key

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

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