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

Answer key

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

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