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

Answer key

  1. 2
  2. font-weight
  3. p
  4. blue
  5. ;
  6. 20px
  7. li
  8. 2
  9. 3
  10. p
  11. 3
  12. 2
  13. font-weight
  14. 8px
  15. 2
  16. color
  17. 8px
  18. { }
  19. 4
  20. 2
  21. 2
  22. 1
  23. h1
  24. 10px
  25. 1
  26. bold
  27. red
  28. 20px
  29. padding
  30. h1
  31. color
  32. 2
  33. 2
  34. italic
  35. border
  36. 2px solid
  37. italic
  38. font-style
  39. p
  40. margin

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