The color rules set down by the CSS stylesheet are thus:

  1. All span elements are red.
  2. Exception to Rule 1: all span elements that are descendants of a div element are blue.
  3. Exception to Rule 2: all span elements that are children of a div element are green.
  4. Exception to all of the above: all span elements that are immediately preceded by a sibling span element (text between them does not count) are colored olive.

This span element is not within a div element, so it is colored red.

The span element in this paragraph are child elements of a p element that is itself a child element of a div element, so they are colored blue. This span element is preceded by an em element, so it is also blue. Since a strong element precedes the next span element it, too, is blue, but the next two span elements are preceded by span elements so they are colored olive.

Since this span element is a child of a div element and preceded by a p element, it is green.