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

Answer key

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

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