css-cascade Flashcards
What are the four components of “the Cascade”?
Source order, inheritance, specificity, and ‘!important’.
What does the term “source order” mean with respect to CSS?
The order that your CSS rules are written in your stylesheet.
How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?
Very possible due to inheritance, the process by which certain CSS properties on a child HTML element can receive value from a parent element.
List the three selector types in order of increasing specificity.
Browsers decide which CSS property values are the most relevant to an element and, therefore, will be applied. based on the matching rules which are composed of different sorts of CSS selectors. Type, class, and ID selectors.
Why is using !important considered bad practice?
Because it makes debugging more difficult by breaking the natural cascading in your stylesheets. When two conflicting declarations with the !important rule are applied to the same element, the declaration with a greater specificity will be applied.