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

Answer key

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

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