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

Answer key

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

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