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

Answer key

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

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