CSS Data Type - <overflow>



The CSS data type <overflow> represents keyword values used for overflow property and the longhand properties overflow-block, overflow-inline, overflow-x, and overflow-y.

Possible Values

<overflow> data type is specified using one of the values listed below.

  • visible: The content is not clipped. It extends beyond the box.

  • hidden: The content is clipped, and the overflow is hidden.

  • clip: The content is clipped at the element's overflow clip edge.

  • scroll: The content is clipped, and a scrollbar is added to allow the user to scroll to see the hidden content.

  • auto: The browser automatically adds a scrollbar when the content overflows.

Syntax

<overflow> = visible | hidden | clip | scroll | auto

CSS <overflow> - Basic Example

In the provided example, the CSS datatype <overflow> is applied to the <pre> elements to regulate the behavior of overflowing content.

Each <pre> element's content determines how it will behave when it exceeds its defined dimensions based on the various values set to overflow.

<html>
<head>
<style>
   pre {
      border: 2px solid black;
      margin-bottom: 3em;     
   }
   ::before {
      font-size: 15px;
      font-weight: bold;
      color: white;
      background: darkorchid;
      display: inline-block;
      width: 100%;
      padding: 5px 10px;
      box-sizing: border-box;
   }
   pre {
      block-size: 110px;
      inline-size: 250px;
   }
   pre:nth-of-type(1) {
      overflow: hidden;
   }
   pre:nth-of-type(1)::before {
      content: "hidden: ";
   }
   pre:nth-of-type(2) {
      overflow: clip;
   overflow-clip-margin: 1em;
   }
   pre:nth-of-type(2)::before {
      content: "clip: ";
   }
   pre:nth-of-type(3) {
      overflow: scroll;
   }
   pre:nth-of-type(3)::before {
      content: "scroll: ";
   }
   pre:nth-of-type(4) {
      overflow: auto;
   }
   pre:nth-of-type(4)::before {
      content: "auto: ";
   }
   pre:nth-of-type(5) {
      overflow: clip;
      overflow: overlay;
      overflow-clip-margin: 3em;
   }
   pre:nth-of-type(5)::before {
      content: "overlay (or clip if not supported): ";
   }
   pre:nth-of-type(6) {
      overflow: visible;
   }
   pre:nth-of-type(6)::before {
      content: "visible: ";
   }
</style>
</head>
<body>
<pre> 
Some say the world will end in fire,
Some say in ice.
From what I've tasted of desire
I hold with those who favour fire.
But if it had to perish twice,
I think I know enough of hate
To say that for destruction ice
Is also great
And would suffice.
<b>-Robert Frost</b>
</pre>
<pre> 
Some say the world will end in fire,
Some say in ice.
From what I've tasted of desire
I hold with those who favour fire.
But if it had to perish twice,
I think I know enough of hate
To say that for destruction ice
Is also great
And would suffice.
<b>-Robert Frost</b>
</pre>
<pre> 
Some say the world will end in fire,
Some say in ice.
From what I've tasted of desire
I hold with those who favour fire.
But if it had to perish twice,
I think I know enough of hate
To say that for destruction ice
Is also great
And would suffice.
<b>-Robert Frost</b>
</pre>
<pre> 
Some say the world will end in fire,
Some say in ice.
From what I've tasted of desire
I hold with those who favour fire.
But if it had to perish twice,
I think I know enough of hate
To say that for destruction ice
Is also great
And would suffice.
<b>-Robert Frost</b>
</pre>
<pre> 
Some say the world will end in fire,
Some say in ice.
From what I've tasted of desire
I hold with those who favour fire.
But if it had to perish twice,
I think I know enough of hate
To say that for destruction ice
Is also great
And would suffice.
<b>-Robert Frost</b>
</pre>
<pre> 
Some say the world will end in fire,
Some say in ice.
From what I've tasted of desire
I hold with those who favour fire.
But if it had to perish twice,
I think I know enough of hate
To say that for destruction ice
Is also great
And would suffice.
<b>-Robert Frost</b>
</pre>
</body>
</html>
Advertisements