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

Answer key

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

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