This happens because box sizing is different between form elements and normal HTML elements. If it's not a form element, the box model used is the one W3C used to preach where border and padding add to the set width
property to make it larger than you specified.
If you don't care about legacy browser support (IE < 8, etc), you can just do this:
div.style {
/* By default, browsers would have set this as content-box */
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
And your border (and any existing horizontal padding) will be part of the width
property of your <div>
.
To do it the other way around, instead of the above:
button.style, textarea.style {
box-sizing: content-box;
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
}
Again, these properties are only supported by modern browsers.