Styling with CSS
Where styles live
The CSS Designer panel manages three sources: external stylesheets (linked via link), embedded style blocks in the head, and inline style attributes. Candidates must know that external sheets are cached and reused across pages, embedded styles apply to one document, and inline styles have the highest author-level specificity short of !important. The panel's All vs. Current selector modes matter: All shows every rule in the source; Current shows rules matching the selection.
Cascade, specificity, inheritance
Specificity is computed as (inline, IDs, classes/attributes/pseudo-classes, elements/pseudo-elements). Equal specificity means later source order wins. Inherited properties (color, font-family) flow to children; non-inherited ones (margin, border) do not. !important overrides normal author declarations.
Traps
- Selector syntax errors silently kill a whole rule; one bad selector in a grouped list can invalidate the group.
- Class vs. ID selectors:
#navoutranks.navregardless of order. - Pseudo-class order for links:
:link,:visited,:hover,:focus,:active(LoVe HAte, with focus before active). - Shorthand resets:
margin: 0wipes all four sides;backgroundshorthand can resetbackground-color. - Units:
emand%are relative;remis relative to the root font size.
Rule of thumb
When asked which rule wins, compare specificity first, then source order; only reach for !important as a last resort. Keep presentation in external sheets so site-wide changes are one edit.