Applying styles.
WHAT IT DOES
Describes how elements should be presented.
WHAT A RULE CONSISTS OF
A selector, identifying what to style Declarations, setting properties to values
WHAT THE CASCADE IS
The process determining which rule applies when several could.
WHAT DECIDES IT
- Origin: browser defaults, then author styles
- Specificity: how precisely the selector targets the element
- Order: later rules win over earlier ones of equal specificity
WHY THAT MATTERS
Most confusion about styles not applying is a cascade question.
WHAT SPECIFICITY IS
A measure of how precise a selector is.
WHAT INCREASES IT
Identifiers count most, then classes and attributes, then element names.
WHAT TO AVOID
Selectors with unnecessary specificity Inline styles, which override almost everything Forcing precedence with an override keyword
WHY THAT LAST ONE
It ends the cascade for that property, and creates problems later.
WHAT INHERITANCE IS
Some properties passing to descendant elements, such as font and colour.
WHAT DOES NOT INHERIT
Layout properties, such as spacing and borders.
WHAT TO CHECK WHEN A STYLE DOES NOT APPLY
The browser's inspector, which shows which rule won and why.