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

Answer key

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

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