Open In App

HTML | DOM Style overflow Property

The Style overflow property in HTML DOM is used to specify the behavior of the content when it overflows the element box. The content may be hidden, shown or a scrollbar maybe shown according to the value. 

Syntax:



object.style.overflow
object.style.overflow = "visible|hidden|scroll|auto|initial|
inherit"

Return Values: It returns a string value, which represents the content that renders outside the element box.

Property Values:



Example: 




<!DOCTYPE html>
<html>
     
<head>
    <title>
        DOM Style overflow Property
    </title>
     
    <style>
        .content {
            background-color: lightgreen;
            height: 150px;
            width: 200px;
            overflow: hidden;
        }
 
        button {
            margin-top: 60px;
        }
    </style>
</head>
 
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
     
    <b>DOM Style overflow Property</b>
     
    <p>
        The Style overflow property in HTML DOM is
        used to specify the behavior of the content
        when it overflows the element box.
    </p>
 
    <div class="content">
        GeeksforGeeks is a computer science portal
        with a huge variety of well written and
        explained computer science and programming
        articles, quizzes and interview questions.
        <br>The portal also has dedicated GATE
        preparation and competitive programming
        sections.
    </div>
     
    <button onclick="setOverflow()">
        Change overflow
    </button>
 
    <!-- Script to set overflow to visible -->
    <script>
        function setOverflow() {
            elem = document.querySelector('.content');
            elem.style.overflow = 'visible';
        }
    </script>
</body>
 
</html>                   

 

 

Example: 




<!DOCTYPE html>
<html>
     
<head>
    <title>
        DOM Style overflow Property
    </title>
     
    <style>
        .content {
            background-color: lightgreen;
            height: 150px;
            width: 200px;
        }
 
        button {
            margin-top: 60px;
        }
    </style>
</head>
 
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
     
    <b>DOM Style overflow Property</b>
     
    <p>
        The Style overflow property in HTML DOM is
        used to specify the behavior of the content
        when it overflows the element box.
    </p>
 
    <div class="content">
        GeeksforGeeks is a computer science portal
        with a huge variety of well written and
        explained computer science and programming
        articles, quizzes and interview questions.
        <br>The portal also has dedicated GATE
        preparation and competitive programming
        sections.
    </div>
     
    <button onclick="setOverflow()">
        Change overflow
    </button>
 
    <!-- Script to set overflow to visible -->
    <script>
        function setOverflow() {
            elem = document.querySelector('.content');
            elem.style.overflow = 'hidden';
        }
    </script>
</body>
 
</html>                   

 

Example: 




<!DOCTYPE html>
<html>
     
<head>
    <title>
        DOM Style overflow Property
    </title>
     
    <style>
        .content {
            background-color: lightgreen;
            height: 150px;
            width: 200px;
            overflow: hidden;
        }
 
        button {
            margin-top: 60px;
        }
    </style>
</head>
 
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
     
    <b>DOM Style overflow Property</b>
     
    <p>
        The Style overflow property in HTML DOM is
        used to specify the behavior of the content
        when it overflows the element box.
    </p>
 
    <div class="content">
        GeeksforGeeks is a computer science portal
        with a huge variety of well written and
        explained computer science and programming
        articles, quizzes and interview questions.
        <br>The portal also has dedicated GATE
        preparation and competitive programming
        sections.
    </div>
     
    <button onclick="setOverflow()">
        Change overflow
    </button>
 
    <!-- Script to set overflow to visible -->
    <script>
        function setOverflow() {
            elem = document.querySelector('.content');
            elem.style.overflow = 'scroll';
        }
    </script>
</body>
 
</html>                   

 

 

Example: 




<!DOCTYPE html>
<html>
     
<head>
    <title>
        DOM Style overflow Property
    </title>
     
    <style>
        .content {
            background-color: lightgreen;
            height: 150px;
            width: 200px;
            overflow: visible;
        }
 
        button {
            margin-top: 60px;
        }
    </style>
</head>
 
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
     
    <b>DOM Style overflow Property</b>
     
    <p>
        The Style overflow property in HTML DOM is
        used to specify the behavior of the content
        when it overflows the element box.
    </p>
 
    <div class="content">
        GeeksforGeeks is a computer science portal
        with a huge variety of well written and
        explained computer science and programming
        articles, quizzes and interview questions.
        <br>The portal also has dedicated GATE
        preparation and competitive programming
        sections.
    </div>
     
    <button onclick="setOverflow()">
        Change overflow
    </button>
 
    <!-- Script to set overflow to visible -->
    <script>
        function setOverflow() {
            elem = document.querySelector('.content');
            elem.style.overflow = 'auto';
        }
    </script>
</body>
 
</html>                   

 

Example: 




<!DOCTYPE html>
<html>
     
<head>
    <title>
        DOM Style overflow Property
    </title>
     
    <style>
        .content {
            background-color: lightgreen;
            height: 150px;
            width: 200px;
            overflow: scroll;
        }
 
        button {
            margin-top: 60px;
        }
    </style>
</head>
 
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
     
    <b>DOM Style overflow Property</b>
     
    <p>
        The Style overflow property in HTML DOM is
        used to specify the behavior of the content
        when it overflows the element box.
    </p>
 
    <div class="content">
        GeeksforGeeks is a computer science portal
        with a huge variety of well written and
        explained computer science and programming
        articles, quizzes and interview questions.
        <br>The portal also has dedicated GATE
        preparation and competitive programming
        sections.
    </div>
     
    <button onclick="setOverflow()">
        Change overflow
    </button>
 
    <!-- Script to set overflow to visible -->
    <script>
        function setOverflow() {
            elem = document.querySelector('.content');
            elem.style.overflow = 'initial';
        }
    </script>
</body>
 
</html>                   

 

 

Example: 




<!DOCTYPE html>
<html>
     
<head>
    <title>
        DOM Style overflow Property
    </title>
     
    <style>
        #parent {
            overflow: auto;
        }
 
        .content {
            background-color: lightgreen;
            height: 150px;
            width: 200px;
        }
 
        button {
            margin-top: 60px;
        }
    </style>
</head>
 
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
     
    <b>DOM Style overflow Property</b>
     
    <p>
        The Style overflow property in HTML DOM is used
        to specify the behavior of the content when it
        overflows the element box.
    </p>
     
    <div id="parent">
        <div class="content">
            GeeksforGeeks is a computer science portal with
            a huge variety of well written and explained
            computer science and programming articles,
            quizzes and interview questions.<br>The portal
            also has dedicated GATE preparation and competitive
            programming sections.
        </div>
    </div>
     
    <button onclick="setOverflow()">
        Change overflow
    </button>
 
    <!-- Script to set overflow to inherit -->
    <script>
        function setOverflow() {
            elem = document.querySelector('.content');
            elem.style.overflow = 'inherit';
        }
    </script>
</body>
 
</html>                   

 

Supported Browsers: The browser supported by DOM Style overflow property are listed below:


Article Tags :