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

Answer key

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

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