div {
padding-top: 50px;
padding-right: 30px;
padding-bottom: 50px;
padding-left: 80px;
}
/* You can also write above code in one line */
div{
padding: 50px 30px 50px 80px; /* top right bottom left; (moving clockwise) */
}
padding: 5px 10px 15px 20px; //top right bottom left
padding: 10px 20px;//top & bottom then left & right
padding-top: 5px; //just top padding
padding-right: 10px; //just right padding
padding-bottom: 15px; //just bottom padding
padding-left: 20px; //just left padding
/*
Padding block is analogous to padding-top and padding-bottom
in a horizontal writing mode. But it behaves like padding-left
and padding-right in a vertical writing mode.
Reference: https://codepen.io/wissamfawaz/pen/mdqgqgd
*/
.text {
background: #fff;
border: 3px dashed #ff7a18;
/* 20px will be added to top and bottom if text is horizontal
20px will be added to left and right if text is vertical
*/
padding-block: 20px;
}
Padding is the defined space around an element
/* Here is how it works */
padding: 10px; /* for all sides i.e. top, bottom, right, left */
padding: 10px 5px; /* top & bottom , right & left */
padding: 10px 5px 15px; /* top, right & left, bottom */
padding: 10px 5px 15px 20px; /* top, right, bottom, left */(clockwide-rotation)
/* Each side can be defined individually */
padding-top: 10px;
padding-right: 5px;
padding-bottom: 15px;
padding-left: 20px;
Syntax:
padding: top, right, bottom, left;
Example:
padding: 10px 15px 20px 25px;
/*What it means*/
padding from top 10px
padding from right 15px
padding from bottom 20px
padding from left 25px
An element's padding area is the space between its content and its border. Note: Padding creates extra space within an element. In contrast, margin creates extra space around an element.