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

Answer key

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

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