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

Answer key

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

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