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

Answer key

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

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