CSS | Overflow

The CSS overflow controls the big content. It tells whether to clip content or to add scroll bars. The overflow contains the following property:

  • visible
  • hidden
  • scroll
  • auto

Visible: The content is not clipped and visible outside the element box.
Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE>
<html>
   <head>
      <style>
         p {
         width:100px;
         height:80px;
         border:1px solid;
         overflow:visible;
         }
      </style>
   </head>
   <body>
      <h2>
         GEEKSFORGEEKS
      </h2>
      <p>
         The CSS overflow controls big content.
         It tells whether to clip content or to add scroll bars.
      </p>
   </body>
</html>

chevron_right


Output:

Hidden: The overflow is clipped and the rest of the content is invisible.

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE>
<html>
   <head>
      <style>
         p {
         width:100px;
         height:80px;
         border:1px solid;
         overflow:hidden;
         }
      </style>
   </head>
   <body>
      <h2>
         GEEKSFORGEEKS
      </h2>
      <p>
         The CSS overflow controls big content.
         It tells whether to clip content or to add scroll bars.
      </p>
   </body>
</html>

chevron_right


Output:


Scroll: The overflow is clipped but a scrollbar is added to see the rest of the content. The scrollbar can be horizontal or vertical.
Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE>
<html>
   <head>
      <style>
         p {
         width:120px;
         height:100px;
         border:1px solid;
         overflow:scroll;
         }
      </style>
   </head>
   <body>
      <h2>
         GEEKSFORGEEKS
      </h2>
      <p>
         The CSS overflow controls big content.
         It tells whether to clip content or to add scroll bars.
      </p>
   </body>
</html>

chevron_right


Output:


Auto: It automatically adds a scrollbar whenever it is required.

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE>
<html>
   <head>
      <style>
         p {
         width:120px;
         height:100px;
         border:1px solid;
         overflow:auto;
         }
      </style>
   </head>
   <body>
      <h2>
         GEEKSFORGEEKS
      </h2>
      <p>
         The CSS overflow controls big content.
         It tells whether to clip content or to add scroll bars.
      </p>
   </body>
</html>

chevron_right


Output:


Overflow-x and Overflow-y: This property specifies how to change the overflow of elements. x deals with horizontal edges and y deals with vertical edges.
Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE>
<html>
   <head>
      <style>
         p {
         width:120px;
         height:100px;
         border:1px solid;
         overflow-x:scroll;
         overflow-y:hidden;
         }
      </style>
   </head>
   <body>
      <h2>
         GEEKSFORGEEKS
      </h2>
      <p>
         The CSS overflow controls big content.
         It tells whether to clip content or to add scroll bars.
      </p>
   </body>
</html>

chevron_right


Output:




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.