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

Answer key

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

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