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

Answer key

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

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