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

Answer key

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

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