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

Answer key

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

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