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

Answer key

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

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