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

Answer key

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

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