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

Answer key

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

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