Previously, this post advocated the use of “text-indent” on a padding-less, border-less, 100% width input. This works, but it’s quite clunky, and old versions of IE don’t support text-indent, so it just looks bad. A much better solution is to
Just use box-sizing.
As pointed out in the comments, the simplest solution is to simply change the box-sizing model of the input element to “border-box”, rather than the default “content-box”. In the example below, I’ve given the containing div a 4px whiteborder.
[sourcecode language=”xhtml”]
[/sourcecode]
Note that for Firefox, you still need to use the -moz- prefix; it’s supported unprefixed in all the other major browsers, though.
Updated 2012-08-03.
Leave a Reply