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

Answer key

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

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