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

Answer key

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

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