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

Answer key

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

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