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

Answer key

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

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