Performance: Overflow property
Controls how content overflow is handled, affecting layout stability and paint performance.
Jump into concepts and practice - no test required
div {
overflow: hidden;
width: 200px;
height: 100px;
}div {
overflow: visible;
width: 200px;
height: 100px;
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| overflow: visible | No extra nodes | Multiple reflows on content change | High paint cost due to overflow spill | [X] Bad |
| overflow: hidden | No extra nodes | Single reflow | Low paint cost due to clipping | [OK] Good |
| overflow: auto | No extra nodes | Reflows on scrollbar appearance | Medium paint cost | [!] OK |
| overflow-y: scroll | No extra nodes | Single reflow | Medium paint cost, stable layout | [OK] Good |
overflow property control in a webpage layout?overflow: hidden; with colon and semicolon.<style>
.box {
width: 100px;
height: 50px;
overflow: scroll;
border: 1px solid black;
}
</style>
<div class='box'>This is a very long text that will not fit inside the box.</div>overflow: scroll;.overflow: visible;. What is the problem and how to fix it?overflow: hidden; which clips content inside the box.hidden to hide it -> Option Dauto adds scrollbars only when content is too big, keeping layout clean otherwise.overflow: auto; because it shows scrollbars only when content overflows -> Option A