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

Answer key

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

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