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

Answer key

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

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