CSS Tutorial 0/203 lessons ~6 min read Lesson 178

    Intermediate: Cascade & Specificity

    intermediate: cascade & specificity cascade & specificity — 25 interview questions with traps, follow-ups, and production context. practice out loud;

    Course progress0%
    Focus
    16 guided sections
    Practice signal
    Examples included
    Career prep
    Interview Q&A included

    Introduction

    Cascade & Specificity — 25 interview questions with traps, follow-ups, and production context. Practice out loud; staff loops reward trade-offs, not definitions.

    Business problem

    Business pressure: Product teams need Cascade & Specificity interview questions to ship polished UI without layout regressions, accessibility lawsuits, or LCP regressions that hurt conversion.

    • Conversion: Visual polish and performance directly affect checkout and signup funnels.
    • Brand: Inconsistent Cascade & Specificity interview questions implementation fragments design system trust.
    • Velocity: CSS debt slows every feature team — architecture matters at scale.

    Why this feature exists

    Platform history: CSS evolved Cascade & Specificity interview questions to solve author needs without JavaScript layout engines or table hacks.

    • Problem solved: Declarative styling separated from document structure.
    • Rejected alternative: Inline styles and JS layout — unmaintainable at enterprise scale.

    Browser rendering perspective

    Rendering impact: Cascade & Specificity interview questions affects style recalculation, layout, paint, and composite stages in the browser pipeline.

    • Chrome (Blink): Style → LayoutNG → Paint → Viz compositor.
    • Firefox (Gecko): Servo-based stylo + WebRender compositing.
    • Safari (WebKit): WebKit style resolver + GPU layer promotion rules.

    Internal browser workflow

    Workflow: Selector match → cascade → computed values → layout tree → paint layers → composite.

    Real production example

    Production: Netflix, Amazon, and Shopify enforce Cascade & Specificity interview questions patterns via design tokens, lint rules, and visual regression CI.

    Enterprise use case

    Enterprise: Design systems (Polaris, Carbon, Atlassian) codify Cascade & Specificity interview questions in token pipelines and component APIs.

    Accessibility considerations

    A11y: CSS must not remove focus visibility, break zoom, or convey state by color alone (WCAG 2.2).

    Performance considerations

    Performance: Cascade & Specificity interview questions can trigger reflow, expensive selectors, or layer explosion — profile with DevTools Performance panel.

    SEO considerations

    SEO: CSS affects LCP, CLS, and mobile usability — ranking signals tied to Core Web Vitals.

    Scalability considerations

    Scale: Cascade & Specificity interview questions choices compound across micro-frontends, white-label tenants, and dark-mode variants.

    Common production issues

    Production failures: Specificity wars, z-index stacks, and responsive breakpoints that work in Chrome but break Safari.

    Debugging guide

    Debug: Chrome DevTools → Elements (computed styles), Layout panel, Rendering layers, Coverage for unused CSS.

    Interview questions

    Explain specificity in CSS cascade.(Intermediate)

    Specificity is (inline, id, class, type). Trap: :is() takes max; :where() zero.

    Follow-up: Calculate .nav#main .link vs .link.active

    Explain inheritance in CSS cascade.(Intermediate)

    Inherit keyword forces inheritance; initial resets to spec default not UA.

    Follow-up: revert vs initial?

    Explain !important in CSS cascade.(Intermediate)

    Use only utilities or a11y overrides — never component defaults.

    Follow-up: How escape !important war?

    Explain @layer in CSS cascade.(Intermediate)

    Layer order declared first wins last in cascade among layers.

    Follow-up: Unlayered vs layered?

    Explain origin in CSS cascade.(Intermediate)

    Author, user, user-agent origins — !important flips user winning.

    Follow-up: What is revert-layer?

    Explain shorthand in CSS cascade.(Intermediate)

    Shorthand resets unspecified longhands — background shorthand wipes previous layers.

    Follow-up: background shorthand trap?

    Explain all property in CSS cascade.(Intermediate)

    all: unset dangerous — resets everything including display.

    Follow-up: When use all?

    Explain cascade layers ITCSS in CSS cascade.(Intermediate)

    ITCSS maps to increasing specificity layers — tokens to utilities.

    Follow-up: ITCSS vs BEM?

    Explain specificity graphs in CSS cascade.(Intermediate)

    Teams track specificity budget per component.

    Follow-up: Max specificity rule?

    Explain :where resets in CSS cascade.(Intermediate)

    :where() zero specificity resets — modern normalize pattern.

    Follow-up: Example reset?

    Explain scoped cascade in CSS cascade.(Intermediate)

    CSS Modules generate unique classes — local cascade.

    Follow-up: Global exceptions?

    Explain important in keyframes in CSS cascade.(Intermediate)

    !important invalid in keyframes declarations.

    Follow-up: Animation override?

    Explain user !important in CSS cascade.(Intermediate)

    User stylesheet !important beats author normal — a11y extensions.

    Follow-up: Browser zoom?

    Explain inline style specificity in CSS cascade.(Intermediate)

    1000 specificity — beats classes unless !important class.

    Follow-up: React inline styles?

    Explain multiple classes in CSS cascade.(Intermediate)

    .a.b specificity 20 — chaining increases weight.

    Follow-up: Single class policy?

    Explain pseudo-element specificity in CSS cascade.(Intermediate)

    ::before counts as type pseudo — low weight.

    Follow-up: ::slotted specificity?

    Explain @scope in CSS cascade.(Intermediate)

    Scoped selector proximity — limits reach without modules.

    Follow-up: @scope vs modules?

    Explain container style query in CSS cascade.(Intermediate)

    @container style() — cascade meets container.

    Follow-up: Use case?

    Explain custom property cascade in CSS cascade.(Intermediate)

    Variables inherit and cascade — not same as preprocessor vars.

    Follow-up: Fallback in var()?

    Explain logical cascade in CSS cascade.(Intermediate)

    Logical properties participate same as physical in cascade.

    Follow-up: margin-block-start specificity?

    Explain dark mode cascade in CSS cascade.(Intermediate)

    [data-theme] attribute selectors — order with media queries.

    Follow-up: Dark token swap?

    Explain third-party CSS in CSS cascade.(Intermediate)

    Load order determines override — isolate with layers.

    Follow-up: Widget CSS conflict?

    Explain utility !important in CSS cascade.(Intermediate)

    Tailwind ! modifier — intentional specificity escape.

    Follow-up: Utility vs component?

    Explain debugging cascade in CSS cascade.(Intermediate)

    DevTools Computed shows winning rule and source.

    Follow-up: Why rule crossed out?

    Explain cascade interview trap in CSS cascade.(Intermediate)

    Candidate says id always beats class without !important context — incomplete.

    Follow-up: Full cascade story?

    Hands-on exercise

    Mock interview drill: Answer all 25 questions out loud in 45 minutes. Record yourself explaining trade-offs, not just definitions.

    Try it yourself

    Edit the CSS panel — the preview updates live. Use DevTools Performance and Accessibility panels to validate.

    Try it yourself

    Preview
    Ready to mark this lesson complete?Track your journey across the entire course.