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

Answer key

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

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