I’m having a problem with the padding in my form on my website.
If I’ve set a height/width to a form element and then adds a padding to it. In all browsers I’ve tried, except Firefox, the padding is added to the height/width.
If I have a input with 200 in width and 20px in height. and padding at 5 (all ways), the sum and total width and height would be 210px and 30px, but in Firefox it is 200px and 20px.
How do I work my way around this?
Give the
inputthis CSS:You can read more about
box-sizingon QuirksMode, the W3C spec, and MDN. Here is its browser support. Use the prefixes-moz-or-webkit-if required by your target browsers.This answer had previously suggested the value
initial, which I had found by using the up/down arrow keys in the Chrome Web Inspector. But it turns out thatinitialis a CSS keyword, applicable to any property, that represents the initial value of the property – the browser’s default value.initialis less safe than explicitly naming which box model to use. Ifbox-sizing: initialwere specified and a browser’s default value forbox-sizingchanged, theinput’s padding could break again.