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

Answer key

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

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