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

Answer key

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

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