Sometimes, we want to prevent the padding property from changing width or height in CSS.
In this article, we’ll look at how to prevent the padding property from changing width or height in CSS.
How to prevent the padding property from changing width or height in CSS?
To prevent the padding property from changing width or height in CSS, we use the box-sizing
property.
For instance, we write
div {
box-sizing: border-box;
}
to prevent the div’s dimensions from changing when there’s padding with box-sizing: border-box;
.
Conclusion
To prevent the padding property from changing width or height in CSS, we use the box-sizing
property.