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

Answer key

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

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