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

Answer key

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

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