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

Answer key

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

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