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

Answer key

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

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