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

Answer key

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

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