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

Answer key

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

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