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

Answer key

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

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