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

Answer key

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

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