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

Answer key

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

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