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

Answer key

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

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