Inheritance in CSS
When HTML elements are not assigned a vale for certain CSS properties, they will inherit CSS properties from another element.
For example, the b element may only have a font weight assigned with no other attributes specified. In this case b would interit things like font family, size, and color from its parent element, p, but would not inherit non-iherited properties like margin, padding, or boarder.
Specificity in CSS
Specificity in CSS refers to the hierarchy given to CSS selectors to break ties between rules competing for the same element. Specificity is inportant because it enables you to target only specific elements with your CSS, giving your more granular control over your styles. For example, given the following CSS rules:
li {color: red}
#nav li {color: blue}
The li elements within the ID #nav will be blue because "li elements inside #nav" is more specific than "any li element." This can be useful if you want to style list elements a certain way, but have the site navigation be styled differently.
Multiple selectors, like ul, li {} target multiple elements: "target ul and li."
A compound selector, like #nav ul li {} , specifies an order to "look" for elements: "look inside #nav, then look inside ul, then target li."
ID and Class Attributes
CSS Classes are a kind of "tag" that can be applied to any HTML element. An HTML element can have multiple classes, and a single class can be applied to multiple HTML elements. ID's are similar to classes, except a particular ID can only be applied to a single element per page. Both ID's and Classes can be used as CSS selectors, giving you the option for more control of your styles.