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

Answer key

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

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