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

Answer key

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

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