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

Answer key

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

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