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

Answer key

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

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