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

Answer key

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

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