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

Programs

css code to design a box using div with following specifications

View Solution


css code to design a circle using div with following specifications

View Solution


css code to change the square into circle when mouse is over to the square shape

View Solution


css code to create 3 different colors box which partially overlapped to each other

View Solution


CSS code to blink text using keyframes

View Solution


Latest Current Affairs 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad