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

Answer key

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

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