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

Answer key

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

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