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

Answer key

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

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