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

Answer key

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

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