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

Answer key

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

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