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

Answer key

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

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