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

Answer key

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

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