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

Answer key

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

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