I want box width and height to include all of the content, padding, border width, and margin by default. Is there a way to do this? Especially, I want to be able to specify
Set the CSS box-sizing
property to border-box
to make width
and height
include the content, border, and padding. This allows you to set width: 100%
and still add padding
or border
. In other words box-sizing: border-box
makes width
include everything between the inner edges of the margin. There is no way to include the margin itself in such a way.
.example { box-sizing: border-box; width: 100%; padding: 10px }