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

Answer key

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

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