Open In App

CSS padding-right Property

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

Syntax: 



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

Property values: 

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






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

Output: 

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




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

Output: 

Example: In this example, we are using padding-right: initial; property.




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

Output: 

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


Article Tags :