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

Answer key

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

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