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

Answer key

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

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