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

Answer key

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

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