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

Answer key

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

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