Padding Shorthand
suggest changeThe padding property sets the padding space on all sides of an element. The padding area is the space between the content of the element and its border. Negative values are not allowed.
Instead of setting each side with padding-top, padding-left, and so on, you can use the shorthand:
Four values:
<style>
.myDiv {
padding: 25px 50px 75px 100px; /* top right bottom left; */
}
</style>
<div class="myDiv"></div>
Three values:
<style>
.myDiv {
padding: 25px 50px 75px; /* top left/right bottom */
}
</style>
<div class="myDiv"></div>
Two values:
<style>
.myDiv {
padding: 25px 50px; /* top/bottom left/right */
}
</style>
<div class="myDiv"></div>
One value:
<style>
.myDiv {
padding: 25px; /* top/right/bottom/left */
}
</style>
<div class="myDiv"></div>
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents