Home > DeveloperSection > Interviews > What is Padding in CSS (Cascading style Sheet) and how to use it ?

Posted on    October-13-2016 5:50 AM

 CSS-CSS3 CSS 
Ratings:
 1 Answer(s)
  62  View(s)
Rate this:

Abhishek Srivasatava
Abhishek Srivasatava

Total Post:70

Points:350
Posted on    October-13-2016 5:50 AM

It is to control the spaces around the content.

there is two way by which we can declare this property:

1st method

p {
    padding-top: 80px;     padding-right: 60px;     padding-bottom: 40px; 
    padding-left: 10px;
    }
 

2nd method

p {
padding: 50px 20px 80px 60px;
}

In the above example, if there is only three value. For example 

p {
padding: 50px 20px 80px;
}

Then top value will be  50px

Left –right  value will be  20px

And button 80px

if there is only two value. for example

 p {
    padding: 50px 20px;
}

Then top & bottom value will be 50px

And Left –right  value will be  20px

If there is only one value. for example

p {
    padding: 50px;
  }

Then top bottom Left & right all have value 50px.


Don't want to miss updates? Please click the below button!

Follow MindStick