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

Answer key

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

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