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

Answer key

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

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