CSS padding-top Property
Description
The padding-top
CSS property is used to define the amount of space or padding added to the top of an element's content box. It effectively creates space between the content and the top border or edge of the element. This property is commonly used in web design to control the spacing and layout of elements within a webpage, ensuring proper alignment and visual separation. By adjusting the padding-top value, designers can control the amount of empty space at the top of an element, enhancing its appearance and positioning within the overall page layout.
- Initial value
- 0
- Applies to
- All elements
- Inherited
- No
- Computed value
- <length> - the percentage as specified or the absolute length
- Animatable
- Yes
- JavaScript syntax
- object.style.paddingTop
Interactive Demo
Syntax
padding-top: [ <length> | <percentage> ]
Values
- <length>Specifies a positive fixed width.
- <percentage>A percentage with respect to the width of the containing block.
- inherit
Example
<div class="layer">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
.layer {
background: #fc3;
border-top: 5px solid #000;
border-bottom: 5px solid #000;
padding: 5px;
padding-top: 40px;
}
Browser Support
The following table will show you the current browser support for the CSS padding-top
property.
Desktop | |||||
12 | 1 | 1 | 3.5 | 1 |
Tablets / Mobile | |||||
18 | 4 | 14 | 1 | 1 | 37 |
Last updated by CSSPortal on: 2nd January 2024