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

Answer key

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

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