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

Answer key

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

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