CSS padding

Unique beauty

CSS Padding:

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:

»length:

This mode is used to specify the size of padding as a fixed value. The size can be set in form of px, cm etc. The default value is 0. It must be non-negative. 

»percentage:

 This mode is used to set the top padding in percentage of the width of the element. It must be non-negative.

»initial: 

It is used to set the padding-top property to its default value. 

»inherit: 

It is used to inherit the padding-top property from its parent element.


CSS padding properties:




paddingIt is used to set all the padding properties in one declaration.
padding-leftIt is used to set left padding of an element.
padding-rightIt is used to set right padding of an element.
padding-topIt is used to set top padding of an element.
padding-bottomIt is used to set bottom padding of an element.



paddingIt is used to set all the padding properties in one declaration.
padding-leftIt is used to set left padding of an element.
padding-rightIt is used to set right padding of an element.
padding-topIt is used to set top padding of an element.
padding-bottomIt is used to set bottom padding of an element.


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

<!DOCTYPE html>
<html>
<head>
    <title>
        padding-top Property
    </title>
 
    <style>
         . course {
            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="course">
        This Medium has a padding-top: 200px;
    </p>
</body>
</html>

Output:  

Padding-top Property 





This Medium has a Padding-top:200px;




Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send