1

Checkbox alignment with its label (i.e., vertical centering) cross different web browsers makes me crazy. Pasted below is standard html code:

<label for="ch"><input id="ch" type="checkbox">My Checkbox</label>

I tested different CSS tricks (e.g., link 1, link 2); most solutions works fine in FF, but are completely off in Chrome or IE8.

I'm looking for any references or pointers to solve this issue. Thanks in advance.

EDIT

According to Elq suggestion I modified the HTML

<div class="row">
<input type="checkbox" id="ch1" />
<label for="ch1">Test</label>
</div>

and CSS

.row{
  display: table-row;
}

label{
  display: table-cell;
  vertical-align: middle;
}

Works now in Firefox, Internet Explorer 8, and Chrome on Windows. Fails on Firefox and Chrome on Linux. Also works in Firefox and Safari on Mac, but fails on Chrome.

Community
  • 1
  • 1
Andrej
  • 3,354
  • 8
  • 35
  • 66

1 Answers1

3

Did you try setting your elements' CSS with 'display:table-cell;'? I've used this trick before when alignment was a problem across browsers.

Elq
  • 151
  • 6
  • Thanks for your response. I modified the code using table-cell. Please see my edited post above. – Andrej Jan 15 '11 at 18:49