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

Answer key

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

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