Table of Contents
INTRODUCTION
The padding-left property defines the space between the left border of an element and its content.
It adds space inside the element, pushing content rightward. It also affects the box model — adding padding-left can increase the total width (unless box-sizing: border-box is set).
Syntax
padding-left: [length] | [percentage];
p{
padding-left: 40px;
border: 1px solid black;
}
An automobile is a self-propelled vehicle designed for transporting people on roads. The automobile has revolutionized modern life by offering flexibility, convenience, and speed in travel. Whether it's a compact automobile for city use or a powerful SUV, the type of automobile someone chooses often reflects their lifestyle.
Accepted Values
The padding-left property should be specified as a single value. It accepts any length units and percentgae values. Like padding property this property also does not accepts negative values. Here's a list of the units that can be used for this property in CSS:
- Absolute Length Units - px, pt, pc, in, cm, mm, Q
- Relative Length Units - em, rem, ex, ch, lh, rlh
- Viewport Units - vw, vh, vmin, vmax
- Percentage Unit - calculated with respect to the width of the containing block
- Global Values - inherit, initial, unset, revert, revert-layer
Frequently Asked Questions (FAQ)
What is the difference between margin-left and padding-left in CSS?
margin-left
- Adds space outside the element, on the left.
- Creates distance from neighboring elements.
- Does not affect the content inside the element.
- Background color does not extend into the margin.
- Can collapse with adjacent vertical margins (only applies to top/bottom margins).
- Adds space inside the element, on the left.
- Pushes content to the right within the element.
- Affects the element’s width unless using box-sizing: border-box.
- Background color does extend into the padding area.
- Cannot collapse..
How to remove default indentation from lists?
ul, ol {
padding-left: 0;
}