Padding
christian.dinh2476 total contributions
Published Aug 8, 2021Updated Apr 19, 2023
Contribute to Docs
The space between the contents of a box and the borders of a box is known as padding. Padding is like the space between a picture and the frame surrounding it.
Syntax
In CSS, you can modify this space with the padding
property.
p.content-header {border: 3px solid coral;padding: 10px;}
Here, the code added 10 pixels of space between the content of the paragraph (the text) and the borders, on all four sides.
The padding
property is often used to expand the background color and make the content look less cramped.
Video Walkthrough
Watch this video on the differences between the CSS margin and padding properties.
If you want to be more specific about the amount of padding on each side of a box’s content, you can use the following properties:
Padding
- padding
- Shorthand property for padding-top, padding-bottom, padding-left and padding-right that sets the space between the content and margin of an element or for each side individually.
- padding-bottom
- Defines the width of the bottom padding for an element.
- padding-left
- Defines the width of the left padding for an element.
- padding-right
- Defines the width of the right padding for an element.
- padding-top
- Defines the width of the top padding for an element.
All contributors
- christian.dinh2476 total contributions
- Anonymous contributorAnonymous contributor3071 total contributions
- CaupolicanDiaz142 total contributions
- sczerman14 total contributions
- christian.dinh
- Anonymous contributor
- CaupolicanDiaz
- sczerman
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.