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

Answer key

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

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