Questions
7 of 26
1What is the overflow property in CSS? Why is the overflow property used?
2What are the possible values for the overflow property? What is the default value of overflow?
3What happens when overflow is not handled in a container with fixed dimensions?
4What is the difference between overflow: hidden and overflow: scroll?
5What is the use of overflow: auto? What is the difference between overflow: auto and overflow: scroll?
6What is the purpose of overflow: visible?
7What is the difference between overflow-x and overflow-y?
8Can you set different overflow behavior for horizontal and vertical directions?
9How does overflow affect child elements that use absolute or fixed positioning?
10How can overflow be used to create scrollable content areas?
11How does overflow interact with padding and margins?
12Does overflow create a new block formatting context (BFC)?
13What is the difference between clip and hidden values for overflow?
14How do browsers handle overflow differently for replaced elements (like <img>, <video>)?
15How do browsers handle overflow differently for replaced elements (like <img>, <video>)?
16What is the difference between overflow: clip and overflow: hidden in CSS Level 4?
17How does overflow interact with position: sticky or position: fixed?
18Can overflow: hidden break position: sticky? Why?
19What’s the difference between using overflow: auto and using overflow: scroll in terms of performance?
20What’s the relationship between overflow and the clip-path property?
21How can you hide overflowing text with ellipsis using CSS?
22What’s the purpose of using text-overflow: ellipsis along with overflow properties?
23How can you make an image fit inside a fixed-size box without overflowing?
24How can you prevent the background from scrolling when a modal is open?
25How would you debug a layout issue where part of the content is being clipped unexpectedly?
26What is the difference between CSS overflow control and JavaScript scroll event control?
07 / 26

What is the difference between overflow-x and overflow-y?

Understanding overflow-x and overflow-y in CSS

The overflow-x and overflow-y properties in CSS control how content that overflows a container is handled horizontally and vertically, respectively. They provide more precise control than the general overflow property, which affects both directions at once.

Key Differences
  1. 1

    overflow-x – Manages overflow along the horizontal axis (left and right).

  2. 2

    overflow-y – Manages overflow along the vertical axis (top and bottom).

  3. 3

    You can use them together to create independent scroll behavior for each axis, such as allowing vertical scrolling but hiding horizontal overflow.

Example: overflow-x vs overflow-y
Difficulty: 3/10
Topics: overflow, scrolling, layout

Scenario Questions

0-2 years experience
  1. 1

    You have a div with a fixed width and height, and you need it to scroll horizontally but never vertically. Which overflow properties would you set and why?

  2. 2

    If you apply overflow: hidden to an element, how does that affect overflow-x and overflow-y, and how would you enable vertical scrolling only?

2-5 years experience
  1. 1

    Our responsive card component sometimes grows too tall on mobile, causing the whole page to scroll. Walk me through how you'd debug the issue and fix it using overflow-x and overflow-y.

  2. 2

    The design spec says tables should scroll horizontally on small screens but never show a vertical scrollbar. How would you implement that with CSS, and what trade‑offs might you consider?

5-8 years experience
  1. 1

    You're redesigning a dashboard where panels can be resized by users and may overflow in both axes. How would you architect the overflow handling to keep behavior consistent and performant across browsers?

  2. 2

    When building a virtualized list that reuses DOM nodes, how does controlling overflow-x versus overflow-y impact scroll event handling and rendering efficiency?

8+ years experience
  1. 1

    Our legacy app is being migrated to a shared component library that must support left‑to‑right and right‑to‑left languages, and dynamic content that can overflow in either direction. How would you design an overflow strategy at the architecture level to avoid layout bugs and keep the code maintainable?

  2. 2

    Multiple teams have introduced inconsistent overflow-x/overflow-y usage, leading to UI glitches on high‑DPI devices. As a staff engineer, how would you establish guidelines and tooling to enforce a consistent overflow policy across the organization?

Follow-up Questions

  • What happens if you set overflow: hidden but then set overflow-x: scroll?
  • How do these properties interact with flexbox or CSS grid containers?
  • Can you describe how the browser decides whether to show a scrollbar for each axis?