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

Answer key

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

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