JavaScriptReactAngularVueSvelteCSSHTMLTypeScript

CSS Interview Questions

70+ most important CSS interview questions covering layouts, animations, responsive design, specificity, and creating engaging interfaces.
Questions and solutions by ex-interviewers
Comprehensive test cases
Code in browser

Questions List

CSS Interview GuidesExplore our starter guides to get a solid grasp of CSS interview prep before jumping into practice.
0/3 guides
GUIDES
  • Job BoardBuild a job board that displays the latest job postings from Hacker News
    Available frameworks
  • ClassnamesImplement a function that conditionally joins CSS class names together
    Languages
  • Classnames IIPremiumImplement a function that conditionally joins CSS class names together and also handles de-duplication and function values
    Languages
  • TabsBuild a tabs component that displays a list of tab elements and one associated panel of content at a time
    Available frameworks
  • Tabs IIPremiumBuild a semi-accessible tabs component that has the right ARIA roles, states, and properties
    Available frameworks
  • getElementsByStyleImplement a function to get all DOM elements that are rendered using the specified style
    Languages
  • AccordionBuild an accordion component that displays a list of vertically stacked sections with each containing a title and content snippet
    Available frameworks
  • Holy GrailBuild the famous holy grail layout consisting of a header, 3 columns, and a footer
    Available frameworks
  • Progress BarsBuild a list of progress bars that fill up gradually when they are added to the page
    Available frameworks
  • jQuery.cssPremiumImplement a jQuery-like function that sets the style of a DOM element
    Languages
  • getElementsByClassNameImplement a function to get all DOM elements that contain the specified classes
    Languages
  • Star RatingBuild a star rating component that shows a row of star icons for users to select the number of filled stars corresponding to the rating
    Available frameworks
  • StopwatchBuild a stopwatch widget that can measure how much time has passed
    Available frameworks
  • Like ButtonBuild a Like button that changes appearance based on its state
    Available frameworks
  • Image CarouselBuild an image carousel that displays a sequence of images
    Available frameworks
  • Image Carousel IIPremiumBuild an image carousel that smoothly transitions between images
    Available frameworks
  • Image Carousel IIIPremiumBuild an image carousel that smoothly transitions between images and has a minimal DOM footprint
    Available frameworks
  • Traffic LightBuild a traffic light where the lights switch from green to yellow to red after predetermined intervals and loop indefinitely
    Available frameworks
  • Digital ClockBuild a 7-segment digital clock that shows the current time
    Available frameworks
  • Tic-tac-toeBuild a tic-tac-toe game that is playable by two players
    Available frameworks
  • Tic-tac-toe IIPremiumBuild an N x N tic-tac-toe game that requires M consecutive marks to win
    Available frameworks
  • Transfer ListBuild a component that allows transferring items between two lists
    Available frameworks
  • Transfer List IIPremiumBuild a component that allows transferring items between two lists, bulk selection/unselection of items, and adding new items
    Available frameworks
  • Modal DialogBuild a reusable modal dialog component that can be opened and closed
    Available frameworks
  • Modal Dialog IIPremiumBuild a semi-accessible modal dialog component that has the right ARIA roles, states, and properties
    Available frameworks
  • Connect FourPremiumBuild a game for two players who take turns to drop colored discs from the top into a vertically suspended board/grid
    Available frameworks
  • Users DatabasePremiumBuild a UI to filter, create, update, and delete users
    Available frameworks
  • Whack-A-MolePremiumBuild a popular arcade game where players attempt to hit moles as they pop up from holes in a board.
    Available frameworks
  • Memory GamePremiumBuild a memory game where the player needs to match pairs of cards
    Available frameworks
  • Selectable CellsPremiumBuild an interface where users can drag to select multiple cells within a grid
    Available frameworks
  • WordlePremiumBuild Wordle, the word-guessing game that took the world by storm
    Available frameworks
  • jQuery Class ManipulationPremiumImplement a set of jQuery-like functions that manipulates classes on a DOM element
    Languages
  • Progress BarPremiumBuild a progress bar component that shows the percentage completion of an operation
    Available frameworks
  • TweetPremiumBuild a component that resembles a Tweet from Twitter
    Available frameworks
  • Analog ClockPremiumBuild an analog clock where the hands update and move like a real clock
    Available frameworks
  • Dice RollerBuild a dice roller app that simulates the results of rolling 6-sided dice
    Available frameworks
  • Grid LightsPremiumBuild a grid of lights where the lights deactivate in the reverse order they were activated
    Available frameworks
  • Progress Bars IIPremiumBuild a list of progress bars that fill up gradually in sequence, one at a time
    Available frameworks
  • Progress Bars IIIPremiumBuild a list of progress bars that fill up gradually concurrently, up to a limit of 3
    Available frameworks
  • Birth Year HistogramPremiumBuild a widget that fetches birth year data from an API and plot it on a histogram
    Available frameworks
  • Pixel ArtPremiumBuild a pixel art drawing tool where users can paint pixels with selected colors
    Available frameworks
  • Auth Code InputPremiumBuild an auth code input component that allows users to enter a 6-digit authorization code
    Available frameworks
  • Progress Bars IVPremiumBuild a list of progress bars that fill up gradually and concurrently, up to a limit of 3, and allow for pausing and resuming
    Available frameworks

CSS Interview Questions and Answers

CSS interviews test more than vocabulary. They test how the language behaves in production: how layout, specificity, the cascade, responsive design, and animations interact when a page has many components, multiple breakpoints, and elements that have to stay sticky on scroll.

Our list of over 74 CSS interview questions and answers is curated by ex-FAANG interviewers who actually conducted these interviews. Each question comes with a worked answer, common mistakes to avoid, and where applicable, an in-browser coding workspace with automated test cases so you can verify your styles in seconds.

The list contains two large categories: CSS coding interview questions (build something) and CSS quiz interview questions (explain how something works).

What CSS interviews actually test

Across every front-end interview round we've seen, CSS questions cluster around six areas:

  • Layouts. Flexbox, Grid, multi-column layouts, sticky positioning, and the classic "three columns, fluid middle, sticky footer" Holy Grail. Junior rounds focus on Flexbox; senior rounds expect fluency in both Flexbox and Grid and the judgment to pick the right one.
  • Specificity and the cascade. When two rules collide, who wins, and why? Includes inline styles versus selectors, !important, the cascade layers introduced in @layer, and inheritance gotchas. Interviewers usually move past textbook definitions and ask you to debug a real selector conflict.
  • Box model and positioning. box-sizing, margin collapse, stacking contexts, position: sticky quirks, and why z-index sometimes does nothing.
  • Responsive design. Media queries, container queries (@container), clamp() for fluid type, and the modern intrinsic-sizing primitives like min-content, max-content, and fit-content.
  • Animations and transitions. When to use transform and opacity for performance, why animating width or height is expensive, the will-change hint, and prefers-reduced-motion.
  • Modern features and architecture. :has() (the parent selector), subgrid, @layer for cascade control, container queries, CSS custom properties, and the architectural debate between BEM, utility-first (Tailwind), and CSS Modules.

Example CSS interview questions

A small sample of the types of questions you'll see, with one-sentence answers. Each links to the full, worked solution.

Layout

  • Question: Build the Holy Grail layout (header, footer, three columns with fluid middle).
    • Answer: The modern answer is CSS Grid with grid-template-areas so the layout shape is declared visibly; Flexbox is the legacy answer most candidates still show.
  • Question: How does Flexbox differ from CSS Grid, and when should you use each?
    • Answer: Flexbox is one-dimensional (row OR column); Grid is two-dimensional. Reach for Grid for page-level layouts where intent should be visible in CSS, and Flexbox for small components and single-axis distribution.

Specificity and the cascade

  • Question: How does CSS selector specificity work?
    • Answer: Specificity is a 4-part tuple: inline, then IDs, then classes/attributes/pseudo-classes, then elements/pseudo-elements. Equal specificity is broken by source order. @layer lets you override the order without inflating selectors.

Box model and positioning

  • Question: Explain the box model and how to switch between content-box and border-box.
    • Answer: Default content-box makes width and height refer to content only; padding and border push the box larger. border-box makes width and height inclusive, which is far easier to reason about and is why most teams set it globally. Switch via box-sizing: border-box.
  • Question: What is the difference between display: none, visibility: hidden, and opacity: 0?
    • Answer: display: none removes the element from the layout entirely. visibility: hidden hides it but reserves space. opacity: 0 shows it transparently and still receives pointer events.

Responsive design

  • Question: Why use rem and em instead of px for typography?
    • Answer: rem scales with the user's root font size, which is critical for accessibility users who increase the default font size in browser settings. px is fixed and bypasses that preference. em scales with the parent's font size, which is useful for component-relative spacing.

Animations

  • Question: Why are transform and opacity the recommended properties for animations?
    • Answer: The browser can animate them on the GPU compositor without recalculating layout or repainting. Animating width, height, top, or left triggers layout work on every frame and is the most common cause of janky animations on mid-tier devices.

Interview difficulty progression

CSS questions track candidate level closely. Here is roughly what to expect at each:

  • Junior (0-2 years). float and clear, basic Flexbox, box-sizing: border-box, simple media queries, specificity tiebreakers, and the difference between position: relative and position: absolute. Building a centered modal or a responsive nav bar.
  • Mid-level (2-5 years). CSS Grid template areas, custom properties (CSS variables), advanced selectors (:not, :nth-child), position: sticky and stacking contexts, why z-index does not always work, and basic animations with @keyframes and transition.
  • Senior (5+ years). Container queries (@container), :has(), subgrid, @layer for cascade control, performance (will-change, content-visibility, contain), CSS architecture tradeoffs (BEM versus utility-first versus CSS Modules), accessibility patterns (focus management, prefers-reduced-motion, prefers-color-scheme), and animating efficiently for low-end devices.

If you are earlier in your career, work through the junior list first and only move on once each item is automatic. At the senior level, the architecture and performance questions carry the most weight in interviewer scoring.

CSS Coding Interview Questions

Master essential CSS techniques and interview patterns by practicing with our list of well-curated CSS coding interview questions. From implementing responsive layouts, creating animations, and handling cross-browser compatibility, to writing maintainable and scalable CSS, we offer numerous practice questions with example answers (solved with code).

Additionally, we provide an in-browser coding workspace, allowing you to style directly in the browser with no setup required. Run your styles against our automated test cases and know if they're accurate within seconds. Moreover, you can further improve your styles and adapt best practices from the well-explained solutions we provide, written by credible and revered former big tech senior/staff engineers.

CSS Quiz Interview Questions

CSS interview trivia questions generally test your CSS know-how and fundamentals. We have the top CSS quiz questions that are commonly asked in such interviews, including important topics like specificity, the box model, flex box, grid, and responsive design. Again, we provide good answers to these questions written by ex-interviewers.