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

Answer key

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

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