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

Answer key

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

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