How to prevent the padding property from changing width or height in CSS?

Spread the love

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.

Leave a Reply

Your email address will not be published. Required fields are marked *