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

Answer key

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

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