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

Answer key

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

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