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

Answer key

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

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