Aligning checkboxes with their labels in a cross-browser way is surprisingly difficult. Hardcode the checkbox's height and width, remove its padding, and make its height plus vertical margins equal to the label's line-height. If the label text is inline, float the checkbox. Firefox, Chrome, and IE7+ all render the following layout identically. In these four examples, the HTML code is identical except for the classes on .example-container
, which alternate between .one-per-line
or .many-per-line
and .unindented
or .indented
.