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

Answer key

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

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