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

Answer key

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

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