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

Answer key

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

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