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

Answer key

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

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