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

Answer key

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

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