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

Answer key

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

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