ryanzec
ryanzec

Reputation: 28040

having the border not expanded the width of an element

I though I remembers there being a css properly that I could set that would allow me to set a border but it would not expand the size of the element. for example, if I set the width to 100 and a border of one 1 all around, the element width becomes 102.

Is their a property to keep the element at 100?

Upvotes: 0

Views: 2193

Answers (2)

thirtydot
thirtydot

Reputation: 228162

You're thinking of box-sizing: border-box.

The spec: http://www.w3.org/TR/css3-ui/#box-sizing

#whatever {
    -webkit-box-sizing: border-box;
       -moz-box-sizing: border-box;
            box-sizing: border-box;
}

Practical usage information: http://html5please.com/#box-sizing

Browser support: http://caniuse.com/css3-boxsizing

Upvotes: 4

John Lawrence
John Lawrence

Reputation: 2923

You can use outline, which does not take up any space:

outline: 1px solid black;

Upvotes: 6

Related Questions