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

Answer key

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

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