CSS Interview-Level Scenarios

What You Learn From This Page

  • How to structure a CSS interview answer around the browser rule, root cause, correction, and trade-offs.
  • How to reason through cascade, specificity, inheritance, box-model, and sizing scenarios.
  • How to solve practical Flexbox, Grid, positioning, stacking, overflow, and responsive-layout questions.
  • How to discuss accessible focus, motion, semantic states, themes, logical properties, and content resilience.
  • How to compare architecture and performance options without claiming one technique is universally superior.
  • How to approach debugging, browser compatibility, and real project scenarios with interview-level judgment.

Introduction

CSS interview scenarios test whether a candidate can explain browser behavior, not merely recall property definitions. Interviewers usually provide a visible symptom or a short code sample and ask why the result occurs, how to correct it, and what trade-offs the correction introduces. A strong answer connects the symptom to the cascade, formatting context, intrinsic sizing, containing block, stacking context, or accessibility model that controls it.

The most reliable answer structure is: identify the relevant browser rule, state the root cause, propose the smallest correct fix, and mention maintainability, accessibility, responsiveness, or browser support when relevant. This approach demonstrates that the candidate can diagnose unfamiliar interfaces rather than repeat memorized snippets.

The examples below are grouped by mechanism so the reasoning transfers between questions. In a real interview, clarify assumptions before coding. Ask about markup, content, browser targets, interaction states, and whether the requested behavior belongs to the component or its parent layout.

Scenario: A Style Does Not Apply

Suppose .card { color: blue; } exists, but the text remains red. Begin by checking whether the stylesheet loaded and whether the selector matches the rendered element. Then inspect the winning declaration in DevTools. A more specific rule, an important declaration, an inline style, a later layer, a transition, or inherited child styling may explain the result.

.card { color: blue; }
.page .card { color: red; }

If both match, the second selector has greater specificity. The interview-level response is not to add !important; it is to identify the actual cascade winner and decide which rule should own the value.

Scenario: Two Selectors Compete

Given .card .title and .card-title, the first has two class selectors while the second has one. If both match the same element and all earlier cascade criteria are tied, the first wins through specificity. If two declarations have equal specificity, the later declaration wins through source order.

A complete answer notes that specificity is not the first cascade criterion. Origin, importance, and cascade layer are considered before specificity. This distinction matters when one rule is important, layered, inline, animated, or supplied by a different origin.

Scenario: Inline and Important Styles

A normal inline style generally outranks normal stylesheet selectors, even very specific ones. An important author declaration changes the importance tier and cannot be overridden by a normal declaration simply by increasing specificity.

The maintainable response is to ask why state is stored inline or why important was introduced. Runtime measurements may legitimately use inline custom properties, while ordinary visual state is often clearer as a class or semantic attribute. Important rules should be narrow and policy-driven rather than routine fixes.

Scenario: Cascade Layers Change the Winner

Consider ordered layers named base, components, and utilities. For normal author declarations, a utility rule in the later utilities layer wins over a component rule in the earlier components layer even if the component selector is more specific.

@layer base, components, utilities;

@layer components {
  .card { color: blue; }
}

@layer utilities {
  .text-danger { color: red; }
}

Normal unlayered author CSS outranks normal layered CSS, which can surprise teams adopting layers incrementally. Important declarations reverse layer priority. A strong candidate inspects layer placement before escalating selectors.

Scenario: A Child Inherits an Unexpected Value

A paragraph inside a blue card inherits color: blue because color is an inherited property. Font family and line height commonly inherit as well, while margin, padding, border, width, and most layout properties do not.

If inheritance is undesirable, define the child's semantic value or adjust the token scope. Avoid resetting every property because that discards useful inheritance and creates more code. The Computed panel can show exactly which ancestor supplied the value.

Scenario: Calculate the Box Model

With content-box, an element declared as 200 pixels wide with 20 pixels of padding on both sides and a five-pixel border on both sides occupies 250 pixels before margin. The width describes only the content box.

.box {
  box-sizing: border-box;
  width: 200px;
  padding: 20px;
  border: 5px solid;
}

Under border-box, the border-box width remains 200 pixels because padding and border are included. This also explains why width: 100% plus padding can overflow under content-box.

Scenario: Choose Flexbox or Grid

Use Flexbox when the primary relationship is one-dimensional, such as distributing controls along a row or arranging a card body in a column. Use Grid when rows and columns need coordinated tracks or items occupy explicit areas. Neither is universally newer or better.

Absolute positioning is not an alternative layout system for ordinary content because it removes items from normal flow. Use it for overlays, badges, and intentional positioned effects. An interview answer should connect the tool to the dimensional requirement.

Scenario: Center Content on Both Axes

A Flexbox container can use justify-content: center and align-items: center. A Grid container can use place-items: center. Explain which axis each property affects rather than presenting a snippet without context.

.container {
  display: grid;
  place-items: center;
}

With flex-direction: column, the main axis is vertical, so justify-content controls vertical distribution and align-items controls horizontal alignment. Axis awareness is a common interview test.

Scenario: A Flex Item Refuses to Shrink

A long text region inside a flex row may overflow even when the row appears fluid. Flex items have an automatic minimum size related to their content, so the item can refuse to become narrower than a long word or intrinsic child.

.row { display: flex; }

.row__content {
  flex: 1 1 auto;
  min-inline-size: 0;
}

Setting the logical minimum to zero permits appropriate shrinking. This is a stronger answer than adding a fixed width because it identifies intrinsic minimum sizing as the root cause.

Scenario: Explain Grow, Shrink, and Basis

If two items have grow factors one and two and 300 pixels of free space remains, they receive approximately 100 and 200 pixels respectively, assuming no other constraints interfere. Grow distributes positive free space as a ratio.

Shrink distributes negative free space and is influenced by base size, so it is not always a simple ratio of final widths. The flex shorthand sets grow, shrink, and basis together. A good answer states the intended sizing behavior instead of using flex: 1 automatically.

Scenario: Push Actions to the Far Edge

In a Flexbox row, margin-inline-start: auto on an actions group absorbs available main-axis space before that item, pushing it toward the end. The logical property adapts to writing direction.

The technique requires free space and the expected main axis. If the container uses a column direction or every item already consumes the available size, the result differs. Explain those constraints during the interview.

Scenario: Equal Grid Columns Still Overflow

Two 1fr tracks may overflow when intrinsic content establishes a nonzero automatic minimum. A long unbreakable identifier can force a track wider than the available space.

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
}

The zero minimum explicitly allows both tracks to shrink. Content may still need wrapping or scrolling according to its meaning. The track fix and the content policy solve different parts of the problem.

Scenario: Build a Responsive Grid Without Breakpoints

A card collection can use repeat(auto-fit, minmax(min(100%, 16rem), 1fr)). The browser creates as many tracks as fit while preventing the minimum from exceeding a very narrow container.

auto-fill retains empty track slots, while auto-fit collapses empty tracks and lets occupied tracks expand. The desired behavior depends on whether empty slots should preserve the grid rhythm.

Scenario: Absolute Positioning Uses the Wrong Reference

An absolutely positioned child uses a containing block, often the nearest positioned ancestor. If it aligns with the page rather than its card, the intended parent may need position: relative.

Relative positioning keeps the parent in normal flow. Absolute positioning removes the child from normal-flow layout. Mention that adding relative positioning can also create a stacking context in some combinations, so it should express a real containment relationship.

Scenario: Sticky Positioning Does Not Work

Check that the sticky element has an inset such as top: 0, enough scroll distance, and an appropriate scroll container. Ancestor overflow, containment, and height constraints can change the sticky boundary.

Sticky remains in normal flow and sticks within its scrolling context. Fixed positioning is removed from normal flow and is usually tied to a viewport or containing block. The distinction is behavioral, not simply two ways to keep a header visible.

Scenario: A Huge Z-Index Still Fails

Z-index values are compared within stacking contexts, not globally. A transformed, filtered, isolated, translucent, contained, or positioned ancestor can create a context that traps descendants below another part of the page.

Inspect ancestor contexts and move the overlay to the appropriate root or correct the context hierarchy. Increasing 999999 to a larger number cannot let a child escape its parent's stacking level.

Scenario: A Dropdown Is Clipped

If a dropdown extends outside a card with overflow: hidden, clipping occurs regardless of the dropdown's z-index. Stacking controls paint order; overflow controls what can be painted outside a box.

Remove unnecessary clipping, move the popup outside the clipping ancestor through a portal, or use an appropriate native popover architecture. Choose based on semantics, focus management, and positioning needs.

Scenario: The Page Scrolls Horizontally

Inspect 100vw, fixed dimensions, minimum widths, long strings, images, transforms, positioned children, and Flexbox or Grid intrinsic sizes. Viewport width can include scrollbar space, making 100vw wider than the page's available content area.

Do not hide the symptom globally. Add responsive media sizing, content wrapping, scrollable code or table containers, or corrected track minimums at the actual source.

Scenario: Ellipsis Does Nothing

Single-line ellipsis normally requires a constrained available width, overflow clipping, and no wrapping in addition to text-overflow: ellipsis.

.title {
  min-inline-size: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

Multi-line truncation uses a different line-clamping technique and requires support and accessibility consideration. Essential information should remain discoverable rather than being silently removed.

Scenario: Compare Hidden States

display: none removes the element from layout and normally from accessibility exposure. visibility: hidden preserves its layout space while hiding it. opacity: 0 makes it transparent but leaves layout and often hit testing intact.

If a transparent item intercepts clicks, pointer-events: none may be appropriate, but focus and accessibility state must also match the intended visibility. Use a proven visually hidden utility when text should remain available to screen readers rather than display: none.

Scenario: Align Items Versus Align Content

align-items aligns individual items within their areas on the cross axis. align-content distributes the entire set of lines or tracks when the container has extra cross-axis space. Align-content may appear inactive when there is only one line or no free space.

This scenario tests whether the candidate understands layout conditions, not just property vocabulary. State the container dimensions and wrapping assumptions before choosing a declaration.

Scenario: A Media Query Does Not Trigger

Check query syntax, effective CSS viewport, browser zoom, mobile viewport metadata, source order, and whether another rule wins after the query. At increased zoom, fewer CSS pixels fit in the window, so breakpoints can trigger at different physical widths.

Mobile-first CSS uses the constrained layout as the baseline and adds capabilities through minimum-width queries as space increases. Breakpoints should occur where content no longer fits comfortably, not simply at a device category named tablet.

Scenario: Choose Media or Container Queries

Use media queries when the condition depends on the viewport or environment. Use container queries when a reusable component should respond to the space allocated by its parent. A card can be narrow in a sidebar and wide in main content at the same viewport width.

.card-shell { container-type: inline-size; }

@container (min-width: 30rem) {
  .card { grid-template-columns: 10rem 1fr; }
}

If the query fails, verify that an eligible ancestor container exists, has the expected size, and is the one selected by the query.

Scenario: Explain Clamp, Min, and Max

clamp(1rem, 3vw, 2rem) chooses a preferred fluid value while keeping it between minimum and maximum bounds. Use it when a value should vary continuously, such as display typography, not when a layout needs a discrete structural switch.

min(90%, 70rem) selects the smaller value, creating a fluid width with an upper bound. max(1rem, env(safe-area-inset-left)) selects the larger value, preserving minimum spacing while respecting a device inset.

Scenario: Build Scalable Dark Mode

Define semantic custom properties at a shared theme boundary and let components consume them. Avoid duplicating every component under a dark selector.

:root {
  --color-background: #ffffff;
  --color-text: #172b3f;
}

[data-theme="dark"] {
  --color-background: #111827;
  --color-text: #f8fafc;
}

A mature product may offer light, dark, and system modes. Custom properties inherit through the DOM, so explain why a token defined on a sidebar affects cards inside that subtree but not cards elsewhere.

Scenario: Theme an SVG Icon

Set an SVG fill or stroke to currentColor. The icon then follows the surrounding CSS color, making hover, disabled, dark-theme, and high-contrast changes easier to coordinate.

.icon-button { color: var(--color-action); }
.icon-button svg { fill: currentColor; }

This is preferable to hardcoded icon colors when the icon belongs to the same semantic foreground role as its label.

Scenario: Hover Is the Only Interaction State

Hover does not cover keyboard and touch input. Essential behavior must be available without it, and keyboard focus needs a visible treatment such as :focus-visible. A parent group can use :focus-within when a focused descendant should highlight the whole field or card.

Use capability queries such as @media (hover: hover) for optional hover animation and @media (pointer: coarse) to adapt touch targets. Do not assume touch means mobile because convertible devices support multiple inputs.

Scenario: Style a Parent from Child State

The relational pseudo-class :has() can style a field containing an invalid input or a card containing selected content. It can replace JavaScript class toggles when the state is already represented in markup.

:is() reduces repeated selector lists, while :where() also groups selectors but contributes zero specificity. Mention browser targets and readability. A direct component state can be clearer than an overly clever relational query.

Scenario: Discuss BEM and Utility-First CSS

BEM uses semantic block, element, and modifier names such as .card, .card__title, and .card--featured. It communicates component ownership and keeps selectors class-based. Avoid encoding every DOM level in names such as .card__header__title.

Utility-first CSS composes small low-specificity classes and can accelerate consistent implementation. Its trade-offs include verbose markup and repeated class groups. Neither architecture is universally superior; the right choice depends on team workflow, framework, design system, scale, and reuse model.

Scenario: Who Owns Component Spacing?

The parent usually owns external placement and space between siblings, while the component owns its internal arrangement and padding. A Flexbox or Grid parent can use gap instead of placing right margins on every child and removing the final margin.

This boundary makes components portable. If a card needs different composition only because a sidebar is narrow, consider a container query before adding .sidebar .card.

Scenario: Native CSS Nesting Changes the Selector

Inside .button, &:hover becomes .button:hover, while a nested .primary without the ampersand targets a descendant. &.primary targets the same element with both classes.

An interview-level answer mentally flattens the selector, considers specificity, and checks target browser or build support. Deep nesting remains undesirable even when the syntax is native because it preserves DOM coupling and specificity growth.

Scenario: Use Progressive Enhancement

Start with a complete basic layout and apply an enhancement through supported syntax or a feature query. Unsupported browsers retain content and actions rather than receiving a broken page.

.layout { display: block; }

@supports (display: grid) {
  .layout {
    display: grid;
    grid-template-columns: 16rem 1fr;
  }
}

Capability detection is generally more reliable than browser-name detection. A strong answer distinguishes progressive enhancement, which starts from the baseline, from graceful degradation, which provides a fallback from an advanced experience.

Scenario: Cross-Browser Output Differs

Compatible browsers do not need pixel-identical font rendering, scrollbars, or native controls. The goal is equivalent content, functionality, accessible interaction, and an acceptably consistent layout.

Validate CSS, create a minimal reproduction, verify exact feature support, test real Blink, Gecko, and WebKit engines, and check known engine behavior. Use the smallest documented workaround only for a confirmed issue. Prefixes should normally be generated from centralized browser targets rather than added manually.

Scenario: Respect Reduced Motion

Animations should communicate feedback or continuity and should not make essential state depend on motion. Add a reduced-motion path for substantial, repeated, or potentially disorienting effects.

@media (prefers-reduced-motion: reduce) {
  .panel {
    animation: none;
    transition: none;
  }
}

A better answer also avoids transition: all, names intentional properties, and verifies that removing motion does not hide state changes.

Scenario: Optimize Animation Performance

Transforms and opacity often animate without changing document layout, while top, left, width, and height can trigger layout and paint. This is guidance, not a guarantee. Record a performance trace when the effect matters.

Large blurs, filters, shadows, and composited layers can still be expensive. will-change should not be applied globally; it consumes resources and is appropriate only when measurement justifies a narrow hint.

Scenario: Prevent Layout Shift

Reserve image space with correct HTML dimensions or an aspect ratio, choose sensible font fallbacks, and provide stable space for asynchronous content such as ads or data panels. Identify which element moved and which late resource caused the movement.

Fixed heights can suppress movement while clipping content, so they are not a universal solution. The goal is predictable reservation with enough flexibility for real content.

Scenario: Handle Mobile Viewport Height

Traditional 100vh can conflict with expanding and collapsing mobile browser chrome. Use a fallback followed by an appropriate modern viewport unit.

.app-shell {
  min-block-size: 100vh;
  min-block-size: 100dvh;
}

Discuss svh, lvh, and dvh based on desired stability. Fullscreen layouts may also need safe-area insets and real-device testing with the virtual keyboard.

Scenario: Make a Header or Sidebar Sticky

A sidebar can use sticky positioning with a block-start offset and align-self: start in a Grid or Flex layout. Verify ancestor overflow and the intended scroll container. For anchor navigation under a sticky header, use scroll-padding-top on the scroller or scroll-margin-top on targets.

This answer shows that sticky visibility and anchor accessibility are related interface concerns, not isolated declarations.

Scenario: Align Card Footers Without Fixed Heights

Make each card a Flexbox column and give the footer margin-block-start: auto. Grid or Flex stretch can make outer cards share track height, while the auto margin consumes remaining internal vertical space.

.card {
  display: flex;
  flex-direction: column;
}

.card__footer { margin-block-start: auto; }

This adapts to different text lengths and avoids fragile fixed card heights.

Scenario: Design a Search Bar

A search row can use Flexbox with a gap. The input receives flexible growth and min-inline-size: 0, while the button keeps its intrinsic size. On very narrow screens, the parent can wrap or switch direction at a content-driven breakpoint.

The answer should include accessible labeling and a real button, not only layout. CSS interview scenarios often test whether visual decisions preserve semantics.

Scenario: Make Tables and Code Work on Mobile

Do not shrink table or code text until it becomes unreadable. Put a wide table inside a region with horizontal overflow and an accessible label where needed. Let code blocks scroll horizontally while keeping the page itself within the viewport.

.table-wrapper,
pre {
  max-inline-size: 100%;
  overflow-x: auto;
}

Horizontal scrolling can be the correct local interaction for data whose relationships should not be broken into arbitrary wrapping.

Scenario: Model Disabled and Expanded States

Use native disabled for a button and style :disabled. Do not simulate disabled state through opacity alone because the control may remain focusable and actionable.

For an accordion, let aria-expanded="true" represent the semantic and behavioral state, then rotate the arrow from that attribute. Visual state should consume the same source of truth that assistive technology receives.

Scenario: Architect CSS for a Large Application

A reasonable architecture may order tokens, reset, base, layouts, components, and utilities through cascade layers. Keep global rules small, component selectors low in specificity, state explicit, and theme decisions in semantic custom properties.

The exact categories can vary. A strong candidate explains ownership, dependency direction, deletion, and how the system prevents overrides from becoming random. Introducing a second architecture for one feature is usually a warning sign.

Scenario: Refactor Important and Legacy CSS

First determine why an important declaration exists. Inspect the competing selector, layer, inline style, or vendor rule. Correct ownership or specificity, remove the important declaration, and regression-test affected states.

For float-based layout, choose Flexbox or Grid according to dimensional needs, then remove clearfix, width compensation, and float-specific margins. Refactoring is complete only when obsolete rules are deleted, not when new CSS is added above them.

Scenario: Explain CSS Modules, Shadow DOM, and Scope

CSS Modules transform class names at build time to reduce global collisions, with a trade-off in tooling dependence and generated names. Shadow DOM provides a stronger style boundary; outside CSS typically customizes internals only through exposed custom properties, inheritance, or ::part().

@scope limits selector reach within a DOM region. These techniques solve related but different ownership problems. Discuss browser support and framework integration rather than presenting encapsulation as absolute.

Scenario: Discuss Units with Nuance

Pixels are valid for precise CSS pixel values, rem units relate to the root font scale, percentages relate to a containing context, fr units distribute Grid space, and viewport or container units depend on their respective reference sizes.

Using rem can respect root-size changes, but accessibility does not come from mechanically converting every pixel. Flexible containers, text growth, zoom behavior, line length, and content resilience matter together. Choose a unit based on what the value should respond to.

Scenario: Diagnose a Real Header Misalignment

Inspect the shared Flexbox container, alignment property, line heights, padding, icon intrinsic size, margins, and actual font metrics. Compare computed box dimensions between aligned and misaligned controls.

Do not nudge one button with a magic top offset until the common rule is understood. A fix at the container or control baseline is usually more robust across labels and browsers.

Scenario: A Child Is Wider Than Its Parent

Check minimum width, content-box padding, no-wrap text, unbreakable strings, replaced elements, Flexbox or Grid intrinsic sizing, transforms, and units such as 100vw. The declared width may be only one contributor.

This question rewards a diagnostic list tied to browser sizing rules. Increasing the parent width hides the symptom rather than explaining it.

Scenario: Prevent CSS Bloat

Use reusable components, semantic tokens, low-specificity ownership, a small global layer, modern layout, generated utilities based on actual usage, and regular dead-code removal. Avoid duplicate variants, one-off page overrides, abandoned prefixes, and permanent old-plus-new systems.

Bundle size is only one metric. Rule count, selector complexity, state coverage, override frequency, and ease of deletion also determine maintenance cost.

Scenario: Answer a Browser Bug Question

Create a minimal reproduction, confirm valid CSS, verify support in the affected version, and search documented engine behavior. Test current Blink, Gecko, and WebKit implementations. If the defect is confirmed, use the narrowest workaround and record browser versions and a removal condition.

Safari deserves separate testing because it uses WebKit, while Chromium browsers use Blink and Firefox uses Gecko. Testing only browser names that share an engine does not provide the same coverage.

Scenario: Explain the Future of CSS

Relevant directions include container queries, native nesting, relational selectors, cascade layers, scoped styling, anchor positioning, view transitions, scroll-driven animation, and advanced color functions. The important interview point is that these features improve expression, component responsiveness, or cascade control.

Fundamentals remain essential: cascade, specificity, inheritance, normal flow, box model, formatting contexts, intrinsic sizing, Flexbox, Grid, positioning, responsive design, and accessibility. New features build on those rules rather than replacing them.

Scenario Categories at a Glance

CategoryTypical QuestionMechanism to Explain
CascadeWhy is my rule overridden?Origin, importance, layer, specificity, order
InheritanceWhy did the child receive this value?Inherited properties and token scope
Box modelWhy is the box wider than declared?Content box, padding, border, sizing model
FlexboxWhy does the child overflow?Intrinsic minimum and flexible sizing
GridWhy does one-fr overflow?Track minimum and intrinsic content
PositioningWhy is absolute relative to the page?Containing block
StackingWhy does z-index fail?Nested stacking contexts
OverflowWhy is a dropdown clipped?Clipping versus paint order
ResponsiveMedia or container query?Viewport versus component space
AccessibilityHow should hidden or focused UI behave?Semantics, exposure, and input modes
ArchitectureBEM, utilities, modules, or layers?Ownership and team trade-offs
PerformanceWhy is animation slow?Layout, paint, compositing, and measurement
CompatibilityWhy does Safari differ?Engine support and documented fallback
DebuggingWhat should be checked first?Computed result and minimal reproduction

The Interview Answer Formula

State the problem in concrete terms, identify the browser rule that governs it, explain the root cause, provide the smallest correct fix, and finish with one relevant best-practice note. For a Flexbox overflow, explain the automatic minimum, show min-inline-size: 0, and mention that fixed-width hacks should be avoided.

When multiple solutions are valid, compare them. Explain when Flexbox versus Grid, media versus container query, clamp versus breakpoint, or component variant versus token is appropriate. This demonstrates engineering judgment rather than attachment to one syntax.

Practical Interview Checklist

  • Clarify markup, content, state, supported browsers, and expected responsive behavior.
  • Name the browser mechanism before proposing a declaration.
  • Distinguish cascade problems from layout, sizing, clipping, and stacking problems.
  • Explain origin, importance, layer, specificity, and source order in the correct sequence.
  • Calculate the box model and account for minimum and maximum constraints.
  • Understand Flexbox axes, free-space distribution, basis, shrinking, and automatic minimums.
  • Understand Grid tracks, intrinsic sizing, implicit placement, auto-fit, and auto-fill.
  • Trace containing blocks, scroll containers, and stacking contexts through ancestors.
  • Use content-driven breakpoints and distinguish viewport from container conditions.
  • Preserve semantic HTML, native state, visible focus, touch use, and reduced motion.
  • Use tokens, logical properties, and parent-owned spacing for portable components.
  • Discuss BEM, utilities, modules, and encapsulation through project trade-offs.
  • Measure performance instead of relying on universal animation rules.
  • Use feature detection, progressive enhancement, and real engine testing.
  • Describe a DevTools and minimal-reproduction workflow for uncertain defects.
  • Avoid important, huge z-index values, fixed dimensions, and browser hacks as default answers.
  • Mention long content, zoom, localization, themes, RTL, and complete interaction states.
  • Prefer the smallest maintainable fix over a snippet that only hides the symptom.

Key Takeaway

A beginner answer often says to add z-index, important, Flexbox, or another media query. An interview-level answer explains why the browser produced the result, which algorithm controls it, what constraint caused the failure, and why the proposed correction is appropriate.

Master the cascade, inheritance, box model, formatting contexts, intrinsic sizing, Flexbox, Grid, positioning, responsive design, accessibility, and debugging workflow. Then use modern CSS where it improves the solution and discuss its support and trade-offs. The strongest candidate does not merely remember properties; they can reason from browser behavior to a small, reusable, accessible fix.