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

Answer key

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

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