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

Answer key

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

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