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

Answer key

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

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