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

Answer key

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

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