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

Answer key

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

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