CSS Overflow

Advertisements

Prev Tutorial Next Tutorial

CSS Overflow

CSS overflow property used to handle the content when it overflows its block level container.

Why need of Overflow ?

Suppose if you do not set the height and width of any box then it goes larger as content, but if you do not set height or width of box but content can not fit inside box then it goes overflow. The CSS overflow property is used to overcome this problem.

CSS Overflow property values

ValuesDescription
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.
initialIt is used to set the property to its initial value.
inheritIt inherits the property from its parent element.

Example: Overflow

<!DOCTYPE html>  
<html>  
<head>  
<style>  
div.scroll {  
    background-color: cyan;  
    width: 100px;  
    height: 150px;  
    overflow: scroll;  
}  
  
div.hidden {  
    background-color: pink;  
    width: 100px;  
    height: 150px;  
    overflow: hidden;  
}  
div.hidden {  
    background-color: yellow;  
    width: 100px;  
    height: 150px;  
    overflow: auto;  
}  
</style>  
</head>  
<body>  
<p>overflow:scroll</p>
<div class="scroll">
If contents goes out the container then 
scroll bar is used to see the rest of the content.
</div>
<p>overflow:hidden</p>
<div class="hidden">
It specifies that the overflow is clipped, 
and rest of the content will be invisible.
</div>
<p>overflow:auto</p>
<div class="auto">
It specifies that if overflow is clipped, 
a scroll bar is needed to see the rest of the content.
</div>

</body>  
</html>

Result

overflow:scroll

If contents goes out the container then scroll bar is used to see the rest of the content.

overflow:hidden

overflow:auto

It specifies that if overflow is clipped, a scroll bar is needed to see the rest of the content.

Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements