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

Answer key

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

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