Padding Properties

CSS padding properties control the space inside an element, between its content and border. Padding ensures proper spacing for readability and design aesthetics.

PropertyPossible ValuesDescription
paddingpx, em, %, autoShorthand for setting all four padding sides
padding-toppx, em, %, autoSpace above the content
padding-rightpx, em, %, autoSpace to the right of the content
padding-bottompx, em, %, autoSpace below the content
padding-leftpx, em, %, autoSpace to the left of the content

Explanation of Values

Value TypeDescriptionExample
px (pixels)Fixed padding sizepadding: 20px;
% (percentage)Relative to parent’s widthpadding: 10%;
em / remRelative to font sizepadding: 2em;
autoBrowser determines the paddingpadding: auto;
padding: 10px 20px 30px 40px;Top → Right → Bottom → Left (clockwise)10px top, 20px right, 30px bottom, 40px left

Example 

.box {
    padding: 20px; /* Adds equal padding on all sides */
}
.container {
    padding: 10px 15px 20px 25px; /* Different padding for each side */
}
✔ First example applies equal padding
✔ Second example applies different padding values
Latest Current Affairs 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2025 Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz