Questions
15 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?
15 / 26

How do browsers handle overflow differently for replaced elements (like <img>, <video>)?

Overflow behavior in replaced elements like images and videos

Replaced elements such as <img>, <video>, or <iframe> have their own intrinsic dimensions and are handled differently by browsers when it comes to overflow. These elements do not generate inner scrollable content—overflow applies only to how their outer box is clipped or constrained.

Key Behaviors
  1. 1

    Replaced elements do not create scrollable overflow regions, even if overflow: auto or overflow: scroll is applied.

  2. 2

    When a replaced element’s content (like a video frame or image) exceeds its container, it is clipped based on the container’s overflow value.

  3. 3

    Using object-fit or object-position can control how replaced content fits within its box rather than relying on overflow.

  4. 4

    overflow on replaced elements themselves is generally ignored because their internal content is rendered externally by the browser or plugin (not in the normal box tree).

Example: Overflow with an Image Container
Difficulty: 5/10
Topics: overflow handling, replaced elements, CSS layout

Scenario Questions

0-2 years experience
  1. 1

    You place an <img> that’s 1200 px wide inside a 300 px‑wide div with overflow: hidden. What does the user see and why?

  2. 2

    If you add overflow: scroll to a <video> element, will scrollbars appear? Explain the browser’s behavior.

  3. 3

    How would you crop an oversized image without stretching it, using only CSS?

2-5 years experience
  1. 1

    A card component sets its image to width:100% but the image’s intrinsic size is larger, and extra whitespace sometimes shows up. Why isn’t overflow being clipped?

  2. 2

    A teammate added overflow:auto to a <video> to let users scroll inside the video frame, but nothing happens. What’s wrong and how would you fix it?

  3. 3

    When deciding between object-fit: cover and setting the container’s overflow to hidden for large images, what trade‑offs should you consider?

5-8 years experience
  1. 1

    Design a photo‑gallery widget that lazily loads high‑resolution images and must allow users to pan inside each image on desktop browsers. How do you handle overflow given browsers ignore overflow on <img>?

  2. 2

    You need a custom video player where users can scroll to view hidden portions of a 4K video in a smaller viewport. What architecture would you use to achieve this despite overflow being ignored on <video>?

  3. 3

    Discuss the performance impact of wrapping replaced elements in extra containers to control overflow versus using CSS transforms or clipping paths.

8+ years experience
  1. 1

    Our legacy app relies on overflow: scroll on many <img> tags to let users pan large diagrams. We’re migrating to a component library and need a consistent, future‑proof solution. What architectural changes would you propose?

  2. 2

    Multiple teams have divergent patterns for handling overflow on replaced elements, causing UI regressions. How would you establish a cross‑team guideline or abstraction to manage this at scale?

  3. 3

    When planning a long‑term migration to Web Components, how would you encapsulate overflow behavior for replaced elements to avoid browser inconsistencies and simplify maintenance?

Follow-up Questions

  • What happens if you set overflow: scroll on an <img>?
  • Can you make a replaced element scrollable without wrapping it?
  • How does object-fit interact with overflow clipping?