The context to which a style rule applies depends on inheritance , specificity , and the cascade . Inheritance depends on document structure . Specificity has to do with the nature of the selector . The cascade has to do with conflicts between multiple style sheets .
Inheritance flows from higher to lower levels in the tree or outline of the document structure.
Hence this paragraph has the same background color as its parent body. Inheritance fails deliberately when common sense informed the creators of CSS that it would be ugly, inconvenient, or otherwise undesirable for inheritance to apply. Inheritance fails by mistake due to certain inconvenient bugs in browsers. For example, Netscape version 4 fails to inherit most styles from body into tables. Specificity Specificity rules resolve conflicts between inheritance, classes, and IDs .This is done by adding up the specificity score for each style rule that could apply to a context.