Inheritance

Some of the CSS attributes, such as fonts and colors, are inherited. Using a mechanism similar to the Chain of Responsibility design pattern, the attributes for a particular HTML element are first searched locally. If the attribute is not defined there then the search is taken to its parent element, and so on.

Some sections of text are inside <p> tags. For this text, the font color is found locally in the <p> tag. The style rule for the <p> tag specifies a green color.
For the text that is inside a <div> tag, the font color is found in the first HTML element up the parent chain that defines the font color, which is the <body> tag. Since the style rule for the <body> tag specifies a blue color, all of the text in <div> tags is colored blue.