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

Answer key

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

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