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

Answer key

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

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