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

Answer key

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

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