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

Answer key

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

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