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

Answer key

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

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