Blog1 min readPremium

CSS Interview Questions That Trip Up Senior Engineers

CSS Interview Questions That Trip Up Senior Engineers

CSS is the topic I see experienced engineers underestimate the most. People spend weeks on JavaScript puzzles, then get asked why a z-index: 9999 isn’t working and freeze.

CSS questions show up in trivia rounds, and they come up constantly during UI builds when your layout doesn’t do what you expect with an interviewer watching. Here are the ones that trip people up, with the explanation I’d give.

1. “How does the browser decide which CSS rule wins?”

How the browser picks a winning CSS rule: origin and importance, inline styles and layers, specificity, source order

Most people jump straight to specificity, but it’s actually the third check. The browser first looks at origin and !important, then inline styles and cascade layers, then specificity, and only then source order.

For specificity, think of it as three numbers (IDs, classes/attributes/pseudo-classes, elements/pseudo-elements) compared left to right:

#nav a          /* (1, 0, 1) */
.nav .link      /* (0, 2, 0) */
.nav a:hover    /* (0, 2, 1)... premium content.
Premium

Keep reading with Premium

Get the rest of this guide plus every premium question, solution, and system design deep dive.

  • All premium solutions
  • System design deep dives
  • Company-specific prep

4.9/5 from our users