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

Answer key

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

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