Css Padding And Its Properties

admin_img Posted By Bajarangi soft , Posted On 10-10-2020

CSS paddings are used to create space around the element, inside any defined border. We can set different paddings for individual sides(top, right, bottom, left). It is important to add border properties to implement padding properties.

Css Paddings

Padding properties can have following values:
1. Length in cm, px, pt, etc.
2. Width % of the element.

Syntax:

 

1. If the padding property has 4 values:
padding: 40px 100px 120px 80px;
top = 40px
right = 100px
bottom = 120px
left = 80px

Example-1

<html>
<head>
    <style>
        p
        {
            padding:80px 100px 50px 80px;
        }
    </style>
</head>
<body>
<h1>
   Bajarangi Soft
</h1>
<p>
    Margin properties
</p>
</body>
</html>
2. If the padding property has 3 values:
padding: 40px 100px 120px;
top = 40px
right and left = 100px
bottom = 120px

Example-2
<html>
<head>
    <style>
        p
        {
            padding:80px 50px 100px;
        }
    </style>
</head>
<body>
<h1>
   Bajarangi Soft
</h1>
<p>
    Margin properties
</p>
</body>
</html>
3. If the padding property has 2 values:
padding: 100px 150px;
top and bottom = 100px;
left and right = 150px;

Example-3
<html>
<head>
    <style>
        p
        {
            padding: 100px 150px;
        }
    </style>
</head>
<body>
<h1>
   Bajarangi Soft
</h1>
<p>
    Margin properties
</p>
</body>
</html>
4. If the padding property has 1 value:
padding: 100px;
top, right, bottom and left = 100px

Example-4
<html>
<head>
    <style>
        p
        {
            padding:100px;
        }
    </style>
</head>
<body>
<h1>
   Bajarangi Soft
</h1>
<p>
    Margin properties
</p>
</body>
</html>

 

Related Post