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

Answer key

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

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