CSS Overflow

The CSS overflow property specifies how to handle the content when it overflows its block level container.

We know that every single element on a page is a rectangular box and the size, positioning and behavior of these boxes are controlled via CSS.

Let’s take an example: If we don’t set the height of the box, it will grow as large as the content. But if we set a specific height or width of the box and the content inside cannot fit then what will happen. The CSS overflow property is used to overcome this problem. It specifies whether to clip content, render scroll bars, or just display content.

Input:-

Index.html
	
<body> 
	  <div class=”scroll”> Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. </div>
</body>

Style.css
.scroll {  
    background-color: #00ffff;  
    width: 100px;  
    height: 100px;  
    overflow: scroll;  
}  

Output:-

ValueDescription
visibleIt specifies that overflow is not clipped. it renders outside the element’s box.this is a default value.
hiddenIt specifies that the overflow is clipped, and rest of the content will be invisible.
scrollIt specifies that the overflow is clipped, and a scroll bar is used to see the rest of the content.
autoIt specifies that if overflow is clipped, a scroll bar is needed to see the rest of the content.
inheritIt inherits the property from its parent element.
initialIt is used to set the property to its initial value.