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

Answer key

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

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