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

Answer key

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

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