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

Answer key

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

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