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

Answer key

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

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