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

Answer key

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

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