Within li
tags, I am placing a checkbox and label input.
If label text is larger than label, the text goes to the next line.
I wrapped the label text but it's not aligning the checkbox and label in the same line if label text is too long.
<li> <input id="checkid" type="checkbox" value="test" /> <label style="word-wrap:break-word">testdata</label> </li>
Thanks,
Method 1: By making the position of checkbox relative, set the vertical-align to the middle can align the checkboxes and their labels. Here, we have made the position of the checkbox relative to the label. So the checkboxes are aligned according to the label.
To align the boxes, add a div wrapper around each label/input, make your label inline-block with a fixed width.
'white-space: nowrap' is the trick I was looking for. Thanks.
The <input type="checkbox"> defines a checkbox. The checkbox is shown as a square box that is ticked (checked) when activated. Checkboxes are used to let a user select one or more options of a limited number of choices. Tip: Always add the <label> tag for best accessibility practices!
Wrap the checkbox with the label and check this
HTML:
<li> <label for="checkid" style="word-wrap:break-word"> <input id="checkid" type="checkbox" value="test" />testdata </label> </li>
CSS:
[type="checkbox"] { vertical-align:middle; }
http://jsfiddle.net/pKD9K/1/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With