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

Answer key

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

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