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

Answer key

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

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