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

Answer key

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

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