Open In App

HTML DOM | Style paddingLeft Property

The Style paddingLeft property is used for setting or returning the left padding of an element. 
The padding property inserts the user desired space within the border of an element.
Syntax : 
 

object.style.paddingLeft
object.style.left = "auto|length|%|initial|inherit"

 



Return Values: It returns a string value, which represents the left padding of an element

Property Values : 
 



Below program illustrates the Style paddingLeft property method :
Example: Setting the left padding of a <div> element.
 




<!DOCTYPE html>
<html>
 
<head>
    <title>Style paddingLeft in HTML</title>
    <style>
        #MyElement {
            border: 1px solid black;
            background-color: green;
            width: 300px;
            height: 300px;
        }
         
        h1 {
            color: green;
        }
         
        h2 {
            font-family: Impact;
        }
         
        body {
            text-align: center;
        }
    </style>
</head>
 
<body>
    <h1>GeeksforGeeks</h1>
    <h2>Style paddingLeft</h2>
 
    <p>For setting the left padding,
      double click the "Apply Left Padding" button: </p>
    <br>
 
    <button ondblclick="padding()">Apply Left Padding</button>
 
    <div id="MyElement">
        Geeksforgeeks is a portal for geeks.
    </div>
 
    <script>
        function padding() {
            document.getElementById("MyElement")
            .style.paddingLeft = "100px";
        }
    </script>
 
</body>
 
</html>

Output: 
 

Supported Browsers: The browser supported byHTML DOM | Style paddingLeft Property are listed below: 
 

 


Article Tags :