Open In App

CSS padding-left Property

Padding is the space between its content and its border. The padding-left property in CSS is used to set the width of the padding area on the left of an element. 

Syntax:



padding-left: length|percentage|initial|inherit;

Property values:

Example 1: In this example, we are using padding-left: length; property.






<!DOCTYPE html>
<html>
<head>
    <title>
        padding-left Property
    </title>
    <style>
        .geek {
            padding-left: 90px;
            color: white;
            background: green;
        }
    </style>
</head>
 
<body>
    <h1 style="color: green;
               text-align:center">
        GeeksforGeeks
    </h1>
 
    <h2 style="text-align:center">
        padding-left Property
    </h2>
 
    <!-- padding-left property used here -->
    <p class="geek">
        This paragraph has a padding-left: 90px;
    </p>
</body>
</html>

Output:

Example 2: In this example, we are using padding-left: percentage; property.




<!DOCTYPE html>
<html>
<head>
    <title>
        padding-left Property
    </title>
    <style>
        .geek {
            padding-left: 25%;
            color: white;
            background: green;
        }
    </style>
</head>
 
<body>
    <h1 style="color: green;
               text-align:center">
        GeeksforGeeks
    </h1>
 
    <h2 style="text-align:center">
        padding-left Property
    </h2>
 
    <!-- padding-left property used here -->
    <p class="geek">
        This paragraph has a padding-left: 25%;
    </p>
</body>
</html>

Output:

Supported Browsers: The browser supported by padding-left property are listed below:


Article Tags :