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

Answer key

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

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