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

Answer key

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

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