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

Answer key

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

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