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

Answer key

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

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