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

Answer key

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

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