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

Answer key

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

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