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

Answer key

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

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