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

Answer key

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

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