Open In App

CSS padding-top Property

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

Syntax:



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

Property Values:

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






<!DOCTYPE html>
<html>
<head>
    <title>
        padding-top Property
    </title>
 
    <style>
        .geek {
            padding-top: 100px;
            width: 50%;
            font-size: 18px;
            border: 1px solid black;
        }
    </style>
</head>
 
<body>
    <h2>
        padding-top Property
    </h2>
 
    <!-- padding property used here -->
    <p class="geek">
        This paragraph has a padding-top: 100px;
    </p>
</body>
</html>

Output:

 

Example: In this example, we are using the padding-top: percentage (%) property.




<!DOCTYPE html>
<html>
<head>
    <title>
        padding-top Property
    </title>
 
    <style>
        .geek {
            padding-top: 10%;
            width: 50%;
            font-size: 18px;
            border: 1px solid black;
        }
    </style>
</head>
 
<body>
    <h2>
        padding-top Property
    </h2>
 
    <!-- padding property used here -->
    <p class="geek">
        This paragraph has a padding-top: 10%;
    </p>
</body>
</html>

Output:

 

Example: In this example, we use padding-top: initial; property.




<!DOCTYPE html>
<html>
<head>
    <title>
        padding-top Property
    </title>
 
    <style>
        .geek {
            padding-top: initial;
            width: 50%;
            font-size: 18px;
            border: 1px solid black;
        }
    </style>
</head>
 
<body>
    <h2>
        padding-top Property
    </h2>
 
    <!-- padding property used here -->
    <p class="geek">
        This paragraph has a padding-top: initial;
    </p>
</body>
</html>

Output:

 

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


Article Tags :