Lead Frontend
​
​
Log inSign up
React interview questionsJavaScript interview questionsTypeScript interview questionsCSS interview questionsHTML interview questionsSenior frontend interview questionsLead frontend engineer interview questionsQuestions by topicCompany guides
© 2026 Lead Frontend. Free educational content, provided as is; it may contain errors. Not affiliated with any company or product named on this site.
TermsPrivacyDisclaimerCopyrightLicenses & credits

CSS Interview Questions

40 questions with answers

CSS questions test whether you understand how the browser lays out a page, not whether you have memorised properties. These questions cover the box model, specificity and the cascade, flexbox and grid, positioning and stacking contexts, and responsive and accessible styling.

How to prepare

  • Explain how specificity and the cascade decide which rule wins.
  • Know when to reach for flexbox vs grid, and how to centre anything both ways.
  • Understand positioning, stacking contexts and what creates a new one.

CSS Interview Questions

1.What are CSS container queries, and how do they change component design compared with media queries?

container-type, named containers, container query units, style queries and the containment trade-offs.

Quiz · CSS
Medium
8 min

2.How do CSS custom properties differ from Sass/Less variables, and how would you use them for theming?

Runtime vs compile-time, inheritance and scoping, @property typing, fallbacks and design-token architecture.

Quiz · CSS
Medium
8 min

3.How do you decide between Flexbox and Grid, and what problem does subgrid solve?

Content-out vs layout-in thinking, intrinsic sizing, auto-fit/minmax, subgrid alignment and accessibility of visual reordering.

Quiz · CSS
Medium
8 min

4.Are you familiar with styling SVG?

Yes, there are several ways to color shapes (including specifying attributes on the object) using inline CSS, an embedded CSS section, or an external CSS file.

Quiz · CSS
Medium
3 min

5.Can you explain the difference between coding a website to be responsive versus using a mobile-first strategy?

Note that these two approaches are not exclusive.

Quiz · CSS
Medium
3 min

6.Can you give an example of an @media property other than screen?

Yes, there are four types of @media properties (including screen):

Quiz · CSS
Medium
3 min

7.How do content-visibility and CSS containment improve rendering performance, and what can go wrong?

contain values, content-visibility: auto, contain-intrinsic-size, and effects on scrollbars, find-in-page and a11y.

Quiz · CSS
Hard
8 min

8.What are CSS cascade layers (@layer), and how would you use them to tame specificity in a large codebase?

Layer order vs specificity, unlayered styles, !important inversion, and layering resets, libraries and utilities.

Quiz · CSS
Hard
8 min

9.What does the CSS :has() selector enable, and what are its performance and specificity gotchas?

The "parent selector", state-driven styling without JS, quantity queries, specificity and invalidation cost.

Quiz · CSS
Medium
7 min

10.What are CSS logical properties, and why do they matter for internationalised products?

Inline/block axes, writing modes, RTL support without overrides, and migration strategy.

Quiz · CSS
Easy
6 min

11.Describe Block Formatting Context (BFC) and how it works.

A Block Formatting Context (BFC) is part of the visual CSS rendering of a web page in which block boxes are laid out. Floats, absolutely positioned elements, in

Quiz · CSS
Medium
3 min

12.Describe floats and how they work.

Float is a CSS positioning property. Floated elements remain a part of the flow of the page, and will affect the positioning of other elements (e.g. text will f

Quiz · CSS
Medium
3 min

13.Describe pseudo-elements and discuss what they are used for.

A CSS pseudo-element is a keyword added to a selector that lets you style a specific part of the selected element(s). They can be used for decoration (:first-li

Quiz · CSS
Medium
3 min

14.Describe what you like and dislike about the CSS preprocessors you have used.

- Mostly the advantages mentioned above.

Quiz · CSS
Medium
3 min

15.Describe z-index and how stacking context is formed.

The z-index property in CSS controls the vertical stacking order of elements that overlap. z-index only affects elements that have a position value which is not

Quiz · CSS
Medium
3 min

16.Explain CSS sprites, and how you would implement them on a page or site.

CSS sprites combine multiple images into one single larger image. It is a commonly-used technique for icons (Gmail uses it). How to implement it:

Quiz · CSS
Medium
3 min

17.Explain how a browser determines what elements match a CSS selector.

This part is related to the above about writing efficient CSS(what-are-some-of-the-gotchas-for-writing-efficient-css). Browsers match selectors from rightmost (

Quiz · CSS
Medium
3 min

18.Explain your understanding of the box model and how you would tell the browser in CSS to render your layout in different box models.

The CSS box model describes the rectangular boxes that are generated for elements in the document tree and laid out according to the visual formatting model. Ea

Quiz · CSS
Medium
3 min

19.How do you build fluid typography and spacing with clamp(), and what are the accessibility pitfalls?

Deriving the preferred value, rem + vw mixing for zoom, container units, and WCAG resize requirements.

Quiz · CSS
Medium
7 min

20.Have you ever used a grid system, and if so, what do you prefer?

Before Flex became popular (around 2014), the float-based grid system was the most reliable because it still has the most browser support among the alternative

Quiz · CSS
Medium
3 min

21.Have you ever worked with retina graphics? If so, when and what techniques did you use?

Retina is just a marketing term to refer to high resolution screens with a pixel ratio bigger than 1. The key thing to know is that using a pixel ratio means th

Quiz · CSS
Medium
3 min

22.Have you played around with the new CSS Flexbox or Grid specs?

Yes. Flexbox is mainly meant for 1-dimensional layouts while Grid is meant for 2-dimensional layouts.

Quiz · CSS
Medium
3 min

23.Have you used or implemented media queries or mobile-specific layouts/CSS?

Yes. An example would be transforming a stacked pill navigation into a fixed-bottom tab navigation beyond a certain breakpoint.

Quiz · CSS
Medium
3 min

24.How do you serve your pages for feature-constrained browsers? What techniques/processes do you use?

- Graceful degradation - The practice of building an application for modern browsers while ensuring it remains functional in older browsers.

Quiz · CSS
Medium
3 min

25.How is responsive design different from adaptive design?

Both responsive and adaptive design attempt to optimize the user experience across different devices, adjusting for different viewport sizes, resolutions, usage

Quiz · CSS
Medium
3 min

26.How would you approach fixing browser-specific styling issues?

- After identifying the issue and the offending browser, use a separate style sheet that only loads when that specific browser is being used. This technique req

Quiz · CSS
Medium
3 min

27.How would you implement a web design comp that uses non-standard fonts?

Use @font-face and define font-family for different font-weights.

Quiz · CSS
Medium
3 min

28.Is there any reason you'd want to use translate() instead of absolute positioning, or vice-versa? And why?

translate() is a value of CSS transform. Changing transform or opacity does not trigger browser reflow or repaint but does trigger compositions; whereas changin

Quiz · CSS
Medium
3 min

29.How does the View Transitions API work for same-document and cross-document navigations?

startViewTransition, view-transition-name, pseudo-element tree, @view-transition for MPAs, support and pitfalls.

Quiz · CSS
Hard
9 min

30.What are some of the "gotchas" for writing efficient CSS?

Firstly, understand that browsers match selectors from rightmost (key selector) to left. Browsers filter out elements in the DOM according to the key selector a

Quiz · CSS
Medium
3 min

31.What are the advantages/disadvantages of using CSS preprocessors?

- CSS is made more maintainable.

Quiz · CSS
Medium
3 min

32.What are the different ways to visually hide content (and make it available only for screen readers)?

These techniques are related to accessibility (a11y).

Quiz · CSS
Medium
3 min

33.What are the various clearing techniques and which is appropriate for what context?

- Empty div method - <div style="clear:both;"</div.

Quiz · CSS
Medium
3 min

34.What does * { box-sizing: border-box; } do? What are its advantages?

- By default, elements have box-sizing: content-box applied, and only the content size is being accounted for.

Quiz · CSS
Medium
3 min

35.What existing CSS frameworks have you used locally, or in production? How would you change/improve them?

- Bootstrap - Slow release cycle. Bootstrap 4 has been in alpha for almost 2 years. Add a spinner button component, as it is widely used.

Quiz · CSS
Medium
3 min

36.What is CSS selector specificity and how does it work?

The browser determines what styles to show on an element depending on the specificity of CSS rules. We assume that the browser has already determined the rules

Quiz · CSS
Medium
3 min

37.What is the CSS display property and can you give a few examples of its use?

- none, block, inline, inline-block, flex, grid, table, table-row, table-cell, list-item.

Quiz · CSS
Medium
3 min

38.What's the difference between a relative, fixed, absolute and statically positioned element?

A positioned element is an element whose computed position property is either relative, absolute, fixed or sticky.

Quiz · CSS
Medium
3 min

39.What's the difference between inline and inline-block?

I shall throw in a comparison with block for good measure.

Quiz · CSS
Medium
3 min

40.What's the difference between "resetting" and "normalizing" CSS? Which would you choose, and why?

- Resetting - Resetting is meant to strip all default browser styling on elements. For e.g. margins, paddings, font-sizes of all elements are reset to be the sa

Quiz · CSS
Medium
3 min

More interview questions

React Interview QuestionsJavaScript Interview QuestionsTypeScript Interview QuestionsHTML Interview QuestionsSenior Frontend Interview QuestionsLead Frontend Engineer Interview QuestionsQuestions by topic