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

Answer key

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

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