HTML CSS examples for CSS Property:overflow
The overflow property sets whether to clip content, display scroll bars or display overflow content when content overflows the element's content area.
The following table summarizes the overflow Property.
Item | Value |
---|---|
Default value: | visible |
Applies to: | Block, inline-block and flex containers |
Inherited: | No |
Animatable: | No. |
The syntax of the property is as follows:
overflow: auto | hidden | scroll | visible | initial | inherit
The following table describes the values of this property.
Value | Description |
---|---|
visible | Content is not clipped, and may overlap other content. This is default value. |
hidden | Content that overflows the element's box is clipped and the rest of the content will be invisible. |
scroll | The overflowing content is clipped, but provides a scrolling mechanism to access the overflowed content. |
auto | If content overflows the element's box it provides scrollbars to see the rest of the content. |
initial | Sets this property to its default value. |
inherit | take the value of its parent element overflow property. |
The example below shows the overflow property.
<!DOCTYPE html> <html lang="en"> <head> <title>Example of CSS overflow property</title> <style type="text/css"> div {<!--from w ww . ja va 2 s .c o m--> width: 250px; height: 150px; border: 1px solid #cccccc; } div.scroll { overflow: scroll; } div.hidden { overflow: hidden; } </style> </head> <body> <h1>Play with the size of div boxes to see how it works</h1> <h2>overflow:scroll</h2> <div class="scroll"> This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. </div> <h2>overflow:hidden</h2> <div class="hidden"> This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. </div> </body> </html>