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

Answer key

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

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