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

Answer key

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

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