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

Answer key

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

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