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

Answer key

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

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