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

Answer key

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

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