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

Answer key

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

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