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

Answer key

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

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