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

Answer key

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

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