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

Answer key

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

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