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

Answer key

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

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