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

Answer key

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

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