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

Answer key

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

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