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

Answer key

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

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