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

Answer key

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

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