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

Answer key

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

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