Frontend Developer Interview Question

What modern CSS features have actually changed how you build components, and what problem do container queries solve?

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

Container queries let a component respond to the width of its container instead of the viewport, so the same card can be narrow in a sidebar and wide in a main column without prop plumbing or breakpoint guesswork. Alongside them, the has selector enables parent styling, native nesting removes a preprocessor dependency, subgrid aligns nested content across a grid, and view transitions animate between states without a library.

Why interviewers ask this

Interviewers use this to date your knowledge. Media queries tied every component to the viewport, which is exactly wrong for a design system, so knowing container queries signals you have built genuinely reusable components. The follow ups probe whether you understand containment cost, fallback strategy and how you decide when a feature is safe to adopt, which is really a question about how you evaluate browser support.

How to structure your answer

  • Explain what container queries fix: viewport is the wrong unit for a component.
  • Name two or three other features you actually use and why.
  • Mention the containment you must declare for it to work.
  • Say how you decide a feature is safe to ship.

Example answer

Spoken example, first person

The big one is container queries, because for years a component's layout was tied to the viewport even though the component has no idea how wide its slot is. So the same card had a prop like variant compact, and that prop had to be threaded from wherever it was placed. Now I declare container type inline size on the wrapper and the card styles itself from its own width, which means it drops into a sidebar or a full width grid and just works. After that, the has selector, mostly for form states, because I can style a field wrapper based on whether it contains an invalid input without touching JavaScript. Native nesting has removed a real preprocessor dependency for me, and subgrid finally makes card headers line up across a row. On support, I check the baseline status rather than guessing, and if a feature is not widely available I use it as progressive enhancement with a supports block so nothing looks broken without it.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • What does declaring container type cost you in terms of layout containment?
  • How would you provide a sensible fallback for a browser without support?
  • Where does the has selector get expensive?

Related frontend developer questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot