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

Answer key

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

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