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

Answer key

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

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